Terraform-provider-aws: Conflict exception when destroying aws_api_gateway_method_response

Created on 29 Jan 2018  ยท  7Comments  ยท  Source: hashicorp/terraform-provider-aws

In the past the same issue was reported when creating a method response (see: https://github.com/terraform-providers/terraform-provider-aws/issues/483).

This was fixed in https://github.com/terraform-providers/terraform-provider-aws/pull/2393.

But, we have run into the same issue during the destruction of the infrastructure. I will create a PR to solve this issue.

bug servicapigateway stale

Most helpful comment

Actually, after doing some "stress tests" on this issue, we have found out that it also affects integration responses (not just method responses).

For instance, we got the following error while creating an infrastructure composed of many API methods.

Error: Error applying plan:

1 error(s) occurred:

* module.method11.aws_api_gateway_integration_response.integration_responses[3]: 1 error(s) occurred:

* aws_api_gateway_integration_response.integration_responses.3: Error creating API Gateway Integration Response: ConflictException: Unable to complete operation due to concurrent modification. Please try again later.
        status code: 409, request id: 805fb7bf-0dad-11e8-87d3-af1cf64e1838

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

It does not seem to exist any public documentation on these constraints (the ability to create API gateway resources in parallel, even if they are not dependent among them). So I was wondering if @radeksimko or some other person from Hashicorp could directly ask Amazon (I am assuming here it would be easier for you to find out, otherwise I can try to contact Amazon myself). Basically, I do not like the idea of patching every single resource in API gateway just in case it is affected by the aforementioned constrained (when some of them might not).

All 7 comments

Actually, after doing some "stress tests" on this issue, we have found out that it also affects integration responses (not just method responses).

For instance, we got the following error while creating an infrastructure composed of many API methods.

Error: Error applying plan:

1 error(s) occurred:

* module.method11.aws_api_gateway_integration_response.integration_responses[3]: 1 error(s) occurred:

* aws_api_gateway_integration_response.integration_responses.3: Error creating API Gateway Integration Response: ConflictException: Unable to complete operation due to concurrent modification. Please try again later.
        status code: 409, request id: 805fb7bf-0dad-11e8-87d3-af1cf64e1838

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

It does not seem to exist any public documentation on these constraints (the ability to create API gateway resources in parallel, even if they are not dependent among them). So I was wondering if @radeksimko or some other person from Hashicorp could directly ask Amazon (I am assuming here it would be easier for you to find out, otherwise I can try to contact Amazon myself). Basically, I do not like the idea of patching every single resource in API gateway just in case it is affected by the aforementioned constrained (when some of them might not).

I did stumble upon this issue - same error, also while destroying.

However for me it was aws_api_gateway_integration.

I have been unable to reproduce it just yet (a couple creates & destroys) but I'll try to give it a closer look and run some more "stress" tests, as you called it.

I'm also seeing this with aws_api_gateway_base_path_mapping:

* aws_api_gateway_base_path_mapping.api.3: Error creating Gateway base path mapping: ConflictException: Unable to complete operation due to concurrent modification. Please try again later.

So, it seems it affects quite a few resources within an API Gateway, not just method responses and integration responses.

@radeksimko Did you have some time to ask Amazon about the exact list of resources affected? I suppose we could just prevent any two resources related to API Gateway from being created/modified/destroyed at the same time. But, that might be an overkill if it is not really needed for all the resources.

Does anyone know of a workaround, or a way to serialize destruction? From the error, I'm unsure which is the other resource(s) involved in the conflict, or how to figure that out. I am having this with destruciton of aws_api_gateway_integration_response

I've tried chaining dependencies of the integration_responses on a single method, adding explicit dependencies on the corresponding method_response and the integration. Some of those things helped an ongoing issue with ConflictException on creation (despite running v0.11.7 where that was supposed to be fixed). But I typically have 1 lingering ConflictException on an integration_response. (across 6 resources with 4 methods and multiple responses each.)

The only solution I've found is to reduce parallelism to 5.

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

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!

Was this page helpful?
0 / 5 - 0 ratings