Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing stage when apply aws_api_gateway_deployment #13

Closed
martinezp opened this issue Jun 12, 2017 · 4 comments
Closed

Missing stage when apply aws_api_gateway_deployment #13

martinezp opened this issue Jun 12, 2017 · 4 comments
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service. upstream-terraform Addresses functionality related to the Terraform core binary.

Comments

@martinezp
Copy link

We are experiencing some issues at the time we deploy our API Gateway into AWS. It seems to be an error recently introduced since we had never seen it before and we haven't really modified our code base.

At the time we are deploying the API for the first time every resource seems to applied correctly. However, at the second and so on deployments, terraform is deleting the old API stage without creating the new one. This especially confusing since when we check the output and .tfstate file the stage seems to have been created correctly. It's only at the time you either hit an end-point or double check the console when you can see that the stage hasn't been created.

After some testing, we have found out that if we change the stage_name we can replicate the behaviour in subsequent deployments. Thus we can reproduce this behaviour:

  1. Run terraform apply with a "dev" stage_name. "dev" stage will be created.
  2. Run terraform apply with a "dev" stage_name. Old "dev" stage will be deleted without the new one being created.
  3. Run terraform apply with a "dev2" stage_name. Old "dev" stage will be deleted and new "dev2" won't be created.
  4. Run terraform apply with a "dev2" stage_name. Back to the missing stage, the old "dev2" stage will be deleted and new "dev2" won't be created.

Terraform Version

0.9.6

Affected Resource(s)

  • aws_api_gateway_deployment

Terraform Configuration Files

resource "aws_api_gateway_deployment" "football_api" {
  lifecycle {
    create_before_destroy = true
  }
  depends_on = [
    <List of aws_api_gateway_integracion dependencies>
  ]
  rest_api_id = "${aws_api_gateway_rest_api.football.id}"
  stage_name = "${var.env}"
  stage_description = "${timestamp()}"
  description = "Deployed ${var.deployed}"
}

Debug Output

https://gist.github.com/martinezp/7662132b5f24463414ebac0a5c413128

Expected Behaviour

Old stage removal, and new stage creation

Actual Behaviour

Old stage removed but no new stage created even though it's apparently been created if we check the .tfstate

Steps to Reproduce

  1. terraform apply
  2. terraform apply
@Ninir Ninir added the bug Addresses a defect in current functionality. label Jun 12, 2017
@radeksimko
Copy link
Member

Hi @martinezp
I was able to reproduce the issue.

Unfortunately this happens because deleting a deployment also causes the stage to be deleted as it was initially created during the deployment. The ideal solution would be managing stage independently of deployments, but that's unfortunately not possible, because you need a deployment ID in order to create a new stage, so this seems to be a closed circle.

We don't have a good mechanism for management of "versioned" resources like API Gateway in Terraform yet. See hashicorp/terraform#6613 for related discussion (which was then migrated to #162)

The solution we're aiming for long-term is to have a first-class support for resource like API Gateway and allow users to manage deployments rather than be limited to a scope a single deployment. This will however take time as it requires some core changes.

I hope the explanation makes sense.

@radeksimko radeksimko added upstream Addresses functionality related to the cloud provider. upstream-terraform Addresses functionality related to the Terraform core binary. and removed upstream Addresses functionality related to the cloud provider. labels Aug 15, 2017
@radeksimko radeksimko added the service/apigateway Issues and PRs that pertain to the apigateway service. label Jan 25, 2018
@sousmangoosta
Copy link
Contributor

@radeksimko I can not reproduce this one till 1.39.0, I think you can close it.

@aeschright
Copy link
Contributor

Hi everyone, thanks for reporting and verifying this. Given the above report that it's no longer broken, I'm going to close the issue. If it happens again with the most recent Terraform and AWS provider releases, please open a new bug report so we can investigate. Thank you!

@ghost
Copy link

ghost commented Nov 3, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service. upstream-terraform Addresses functionality related to the Terraform core binary.
Projects
None yet
Development

No branches or pull requests

5 participants