provider/aws: Expose invoke ARN from Lambda function (for APIG) (#13890)

This commit is contained in:
Radek Simko 2017-04-24 20:47:11 +02:00 committed by GitHub
parent 28851ef5d9
commit cda84b1674
3 changed files with 13 additions and 0 deletions

View File

@ -146,6 +146,10 @@ func resourceAwsLambdaFunction() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
}, },
"invoke_arn": {
Type: schema.TypeString,
Computed: true,
},
"last_modified": { "last_modified": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@ -406,6 +410,8 @@ func resourceAwsLambdaFunctionRead(d *schema.ResourceData, meta interface{}) err
d.Set("version", lastVersion) d.Set("version", lastVersion)
d.Set("qualified_arn", lastQualifiedArn) d.Set("qualified_arn", lastQualifiedArn)
d.Set("invoke_arn", buildLambdaInvokeArn(*function.FunctionArn, meta.(*AWSClient).region))
return nil return nil
} }

View File

@ -2011,3 +2011,9 @@ func flattenCognitoIdentityProviders(ips []*cognitoidentity.Provider) []map[stri
return values return values
} }
func buildLambdaInvokeArn(lambdaArn, region string) string {
apiVersion := "2015-03-31"
return fmt.Sprintf("arn:aws:apigateway:%s:lambda:path/%s/functions/%s/invocations",
region, apiVersion, lambdaArn)
}

View File

@ -108,6 +108,7 @@ For **environment** the following attributes are supported:
* `arn` - The Amazon Resource Name (ARN) identifying your Lambda Function. * `arn` - The Amazon Resource Name (ARN) identifying your Lambda Function.
* `qualified_arn` - The Amazon Resource Name (ARN) identifying your Lambda Function Version * `qualified_arn` - The Amazon Resource Name (ARN) identifying your Lambda Function Version
(if versioning is enabled via `publish = true`). (if versioning is enabled via `publish = true`).
* `invoke_arn` - The ARN to be used for invoking Lambda Function from API Gateway - to be used in [`aws_api_gateway_integration`](/docs/providers/aws/r/api_gateway_integration.html)'s `uri`
* `version` - Latest published version of your Lambda Function. * `version` - Latest published version of your Lambda Function.
* `last_modified` - The date this resource was last modified. * `last_modified` - The date this resource was last modified.
* `kms_key_arn` - (Optional) The ARN for the KMS encryption key. * `kms_key_arn` - (Optional) The ARN for the KMS encryption key.