Terraform v0.6.15
https://gist.github.com/JefStat/9cb343c0ee66366aa060e7db55fbcef6
https://gist.github.com/JefStat/9ffa536e973066c67e627d7e77aa0ac9
Should update lambda function
Error invalid lambda function
terraform applyI haven't personally used stage variables (yet), I'm wondering if API Gateway deployment is eventually consistent ...
I plan to work on aws_api_gateway_stage resource so I might have a look at this bug too.
Any new on this? I think is mandatory when using Lambda, or you would have to create different API for different stages.
Is there a time frame on integrating this feature into the solution?
I am also running into this issue. I would like to create one deployment per lambda alias but I am unable to reference the stage variables in the uri in the aws_api_gateway_integration
I'm using 0.9.2 and its working for me like this:
resource "aws_api_gateway_integration" "my-integration" {
...
uri = "arn:aws:apigateway:${var.region}:lambda:path/2015-03-31/functions/${aws_lambda_function.my-lambda.arn}:$${stageVariables.lambdaAlias}/invocations"
...
}
@gnp how do you avoid the circular dependency? My deployment depends on the integration
resource "aws_api_gateway_deployment" "query_builder_deployment" {
depends_on = [
"aws_api_gateway_method.query_builder_post",
"aws_api_gateway_integration.query_builder_integration",
"aws_api_gateway_integration_response.query_builder_integration_response",
"aws_api_gateway_method_response.query_builder_post_200"
]
...
oh I see, you're not referencing the variable directly so that avoids it, would you mind posting your aws_api_gateway_deployment block?
resource "aws_api_gateway_deployment" "test" {
depends_on = ["aws_api_gateway_integration.my-integration"]
rest_api_id = "${aws_api_gateway_rest_api.my-api.id}"
stage_name = "test"
variables = {
"lambdaAlias" = "TEST"
}
}
This worked for me:
Changed the uri in the aws_api_gateway_integration resource from:
arn:aws:apigateway:${var.aws_region}:lambda:path/2015-03-31/functions/$${stageVariables.lambdaFunction}/invocations
to:
arn:aws:apigateway:${var.aws_region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${var.aws_region}:${var.account_id}:function:$${stageVariables.lambdaFunction}/invocations
where ${var.account_id} can be the id of your AWS account or '*'
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
I'm using 0.9.2 and its working for me like this: