'Updating my APIGW deployment with Terraform?
I understand the title looks weird, but I'll do my best to explain it. Right now, my APIGW deployment looks like this:
resource "aws_api_gateway_rest_api" "apig" {
body = "${file("../json-resolved/swagger.json")}"
name = "apig"
}
resource "aws_api_gateway_deployment" "apig_deployment" {
rest_api_id = aws_api_gateway_rest_api.apig.id
triggers = {
redeployment = sha1(jsonencode(aws_api_gateway_rest_api.apig.body))
}
lifecycle {
create_before_destroy = true
}
}
Now, the API itself has some variables, for example, the AWS Function URI: region, account_id and stage variable (environment). The way I did that before was by using:
aws apigateway put-rest-api --rest-api-id $Gateway_ID --mode overwrite --body fileb://$Build_SourcesDirectory/json-resolved/swagger.json
aws apigateway create-deployment --rest-api-id $Gateway_ID --stage-name $ENV --variables environment=$ENV
How do I do the same with Terraform?
Solution 1:[1]
Create an aws_api_gateway_stage in Terraform. Define the environment variables in the aws_api_gateway_stage. See the first example in the aws_api_gateway_deployment documentation, which includes an aws_api_gateway_stage.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mark B |
