Skip to content

Commit

Permalink
Merge pull request #14 from szilveszter/api-gateway-change-workaround
Browse files Browse the repository at this point in the history
Introduce lifecycle configuration to allow proper resource recreation
  • Loading branch information
szilveszter authored Nov 9, 2017
2 parents f3574d8 + 6637c65 commit eebfc4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/apigateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ resource "aws_api_gateway_rest_api" "api" {
}

resource "aws_api_gateway_deployment" "stage" {
depends_on = ["aws_api_gateway_rest_api.api"]

rest_api_id = "${aws_api_gateway_rest_api.api.id}"
stage_name = "${var.stage}"

variables = {
"version" = "${md5(data.template_file.swagger_file.rendered)}"
}

lifecycle {
create_before_destroy = true
}
}

data "aws_acm_certificate" "ssl_cert" {
Expand Down
5 changes: 4 additions & 1 deletion modules/apigateway/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ output "api_id" {
value = "${aws_api_gateway_rest_api.api.id}"
}
output "invoke_url" {
value = "${aws_api_gateway_deployment.stage.invoke_url}"
# If we have a custom domain set up, we should point the endpoint to that.
# Otherwise take the deployment's invoke URL, and strip the intermediary
# stage suffix from the URL.
value = "${var.enable_custom_domain ? format("https://%s", var.custom_domain) : aws_api_gateway_deployment.stage.invoke_url}"
}

0 comments on commit eebfc4a

Please sign in to comment.