-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
API Gateway REST API Race Conditions #26051
API Gateway REST API Race Conditions #26051
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of questions and comments - overall looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀.
% make testacc TESTARGS='-run=TestAccAPIGatewayRestAPI' PKG=apigateway ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/apigateway/... -v -count 1 -parallel 3 -run=TestAccAPIGatewayRestAPI -timeout 180m
=== RUN TestAccAPIGatewayRestAPIDataSource_basic
=== PAUSE TestAccAPIGatewayRestAPIDataSource_basic
=== RUN TestAccAPIGatewayRestAPIDataSource_Endpoint_vpcEndpointIDs
=== PAUSE TestAccAPIGatewayRestAPIDataSource_Endpoint_vpcEndpointIDs
=== RUN TestAccAPIGatewayRestAPIPolicy_basic
=== PAUSE TestAccAPIGatewayRestAPIPolicy_basic
=== RUN TestAccAPIGatewayRestAPIPolicy_disappears
=== PAUSE TestAccAPIGatewayRestAPIPolicy_disappears
=== RUN TestAccAPIGatewayRestAPIPolicy_Disappears_restAPI
=== PAUSE TestAccAPIGatewayRestAPIPolicy_Disappears_restAPI
=== RUN TestAccAPIGatewayRestAPI_basic
=== PAUSE TestAccAPIGatewayRestAPI_basic
=== RUN TestAccAPIGatewayRestAPI_tags
=== PAUSE TestAccAPIGatewayRestAPI_tags
=== RUN TestAccAPIGatewayRestAPI_disappears
=== PAUSE TestAccAPIGatewayRestAPI_disappears
=== RUN TestAccAPIGatewayRestAPI_endpoint
=== PAUSE TestAccAPIGatewayRestAPI_endpoint
=== RUN TestAccAPIGatewayRestAPI_Endpoint_private
=== PAUSE TestAccAPIGatewayRestAPI_Endpoint_private
=== RUN TestAccAPIGatewayRestAPI_apiKeySource
=== PAUSE TestAccAPIGatewayRestAPI_apiKeySource
=== RUN TestAccAPIGatewayRestAPI_APIKeySource_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_APIKeySource_overrideBody
=== RUN TestAccAPIGatewayRestAPI_APIKeySource_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_APIKeySource_setByBody
=== RUN TestAccAPIGatewayRestAPI_binaryMediaTypes
=== PAUSE TestAccAPIGatewayRestAPI_binaryMediaTypes
=== RUN TestAccAPIGatewayRestAPI_BinaryMediaTypes_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_BinaryMediaTypes_overrideBody
=== RUN TestAccAPIGatewayRestAPI_BinaryMediaTypes_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_BinaryMediaTypes_setByBody
=== RUN TestAccAPIGatewayRestAPI_body
=== PAUSE TestAccAPIGatewayRestAPI_body
=== RUN TestAccAPIGatewayRestAPI_description
=== PAUSE TestAccAPIGatewayRestAPI_description
=== RUN TestAccAPIGatewayRestAPI_Description_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_Description_overrideBody
=== RUN TestAccAPIGatewayRestAPI_Description_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_Description_setByBody
=== RUN TestAccAPIGatewayRestAPI_disableExecuteAPIEndpoint
=== PAUSE TestAccAPIGatewayRestAPI_disableExecuteAPIEndpoint
=== RUN TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_overrideBody
=== RUN TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_setByBody
=== RUN TestAccAPIGatewayRestAPI_Endpoint_vpcEndpointIDs
=== PAUSE TestAccAPIGatewayRestAPI_Endpoint_vpcEndpointIDs
=== RUN TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideBody
=== RUN TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_mergeBody
=== PAUSE TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_mergeBody
=== RUN TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideToMergeBody
=== PAUSE TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideToMergeBody
=== RUN TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_setByBody
=== RUN TestAccAPIGatewayRestAPI_minimumCompressionSize
=== PAUSE TestAccAPIGatewayRestAPI_minimumCompressionSize
=== RUN TestAccAPIGatewayRestAPI_MinimumCompressionSize_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_MinimumCompressionSize_overrideBody
=== RUN TestAccAPIGatewayRestAPI_MinimumCompressionSize_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_MinimumCompressionSize_setByBody
=== RUN TestAccAPIGatewayRestAPI_Name_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_Name_overrideBody
=== RUN TestAccAPIGatewayRestAPI_parameters
=== PAUSE TestAccAPIGatewayRestAPI_parameters
=== RUN TestAccAPIGatewayRestAPI_Policy_basic
=== PAUSE TestAccAPIGatewayRestAPI_Policy_basic
=== RUN TestAccAPIGatewayRestAPI_Policy_order
=== PAUSE TestAccAPIGatewayRestAPI_Policy_order
=== RUN TestAccAPIGatewayRestAPI_Policy_overrideBody
=== PAUSE TestAccAPIGatewayRestAPI_Policy_overrideBody
=== RUN TestAccAPIGatewayRestAPI_Policy_setByBody
=== PAUSE TestAccAPIGatewayRestAPI_Policy_setByBody
=== CONT TestAccAPIGatewayRestAPIDataSource_basic
=== CONT TestAccAPIGatewayRestAPI_Description_setByBody
=== CONT TestAccAPIGatewayRestAPI_apiKeySource
--- PASS: TestAccAPIGatewayRestAPIDataSource_basic (22.82s)
=== CONT TestAccAPIGatewayRestAPI_Description_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_apiKeySource (56.39s)
=== CONT TestAccAPIGatewayRestAPI_description
--- PASS: TestAccAPIGatewayRestAPI_Description_overrideBody (61.48s)
=== CONT TestAccAPIGatewayRestAPI_body
--- PASS: TestAccAPIGatewayRestAPI_description (38.93s)
=== CONT TestAccAPIGatewayRestAPI_BinaryMediaTypes_setByBody
--- PASS: TestAccAPIGatewayRestAPI_BinaryMediaTypes_setByBody (24.96s)
=== CONT TestAccAPIGatewayRestAPI_BinaryMediaTypes_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_body (84.67s)
=== CONT TestAccAPIGatewayRestAPI_binaryMediaTypes
--- PASS: TestAccAPIGatewayRestAPI_BinaryMediaTypes_overrideBody (73.04s)
=== CONT TestAccAPIGatewayRestAPI_APIKeySource_setByBody
--- PASS: TestAccAPIGatewayRestAPI_APIKeySource_setByBody (20.34s)
=== CONT TestAccAPIGatewayRestAPI_APIKeySource_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_APIKeySource_overrideBody (49.97s)
=== CONT TestAccAPIGatewayRestAPI_minimumCompressionSize
--- PASS: TestAccAPIGatewayRestAPI_minimumCompressionSize (42.58s)
=== CONT TestAccAPIGatewayRestAPI_Policy_setByBody
--- PASS: TestAccAPIGatewayRestAPI_Policy_setByBody (20.45s)
=== CONT TestAccAPIGatewayRestAPI_Policy_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_Policy_overrideBody (42.54s)
=== CONT TestAccAPIGatewayRestAPI_Policy_order
--- PASS: TestAccAPIGatewayRestAPI_Policy_order (23.97s)
=== CONT TestAccAPIGatewayRestAPI_Policy_basic
--- PASS: TestAccAPIGatewayRestAPI_Policy_basic (31.86s)
=== CONT TestAccAPIGatewayRestAPI_parameters
--- PASS: TestAccAPIGatewayRestAPI_parameters (36.24s)
=== CONT TestAccAPIGatewayRestAPI_Name_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_Name_overrideBody (42.13s)
=== CONT TestAccAPIGatewayRestAPI_MinimumCompressionSize_setByBody
--- PASS: TestAccAPIGatewayRestAPI_MinimumCompressionSize_setByBody (17.42s)
=== CONT TestAccAPIGatewayRestAPI_MinimumCompressionSize_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_binaryMediaTypes (379.65s)
=== CONT TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_MinimumCompressionSize_overrideBody (74.19s)
=== CONT TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_setByBody
--- PASS: TestAccAPIGatewayRestAPI_Description_setByBody (700.68s)
=== CONT TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_setByBody
--- PASS: TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_setByBody (31.40s)
=== CONT TestAccAPIGatewayRestAPI_Endpoint_vpcEndpointIDs
--- PASS: TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideBody (196.09s)
=== CONT TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_mergeBody
--- PASS: TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_setByBody (222.01s)
=== CONT TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_overrideBody
--- PASS: TestAccAPIGatewayRestAPI_DisableExecuteAPIEndpoint_overrideBody (42.59s)
=== CONT TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideToMergeBody
--- PASS: TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_mergeBody (235.85s)
=== CONT TestAccAPIGatewayRestAPI_disableExecuteAPIEndpoint
--- PASS: TestAccAPIGatewayRestAPI_disableExecuteAPIEndpoint (42.71s)
=== CONT TestAccAPIGatewayRestAPI_basic
--- PASS: TestAccAPIGatewayRestAPI_Endpoint_vpcEndpointIDs (297.55s)
=== CONT TestAccAPIGatewayRestAPIPolicy_disappears
--- PASS: TestAccAPIGatewayRestAPI_EndpointVPCEndpointIDs_overrideToMergeBody (170.65s)
=== CONT TestAccAPIGatewayRestAPI_Endpoint_private
--- PASS: TestAccAPIGatewayRestAPI_Endpoint_private (18.33s)
=== CONT TestAccAPIGatewayRestAPIPolicy_Disappears_restAPI
--- PASS: TestAccAPIGatewayRestAPIPolicy_disappears (27.21s)
=== CONT TestAccAPIGatewayRestAPI_endpoint
--- PASS: TestAccAPIGatewayRestAPI_endpoint (50.81s)
=== CONT TestAccAPIGatewayRestAPI_disappears
--- PASS: TestAccAPIGatewayRestAPIPolicy_Disappears_restAPI (60.97s)
=== CONT TestAccAPIGatewayRestAPI_tags
--- PASS: TestAccAPIGatewayRestAPI_disappears (15.72s)
=== CONT TestAccAPIGatewayRestAPIPolicy_basic
--- PASS: TestAccAPIGatewayRestAPI_tags (45.40s)
=== CONT TestAccAPIGatewayRestAPIDataSource_Endpoint_vpcEndpointIDs
--- PASS: TestAccAPIGatewayRestAPIPolicy_basic (74.43s)
--- PASS: TestAccAPIGatewayRestAPI_basic (208.82s)
--- PASS: TestAccAPIGatewayRestAPIDataSource_Endpoint_vpcEndpointIDs (137.01s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/apigateway 1299.523s
@AdamTylerLynch Thanks for the contribution 🎉 👏. |
This functionality has been released in v4.25.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
This PR is to resolve a subtle race condition that occurs when a user is importing (create or update) OpenAPI Specifications and has one or more Private Endpoints associated with the API Gateway. The private endpoints can be defined as Terraform configuration or in the
x-amazon-apigateway-endpoint-configuration
extensions of OpenAPI.Terraform by default uses the
put_rest_api_mode
ofoverwrite
when importing the OpenAPI Specification (create or update). This causes the AWS control plane to delete existing literal properties if they are not explicitly set in the OpenAPI definition. Terraform attempts to compensate for this by creating (or deleting and then creating) impacted properties (Impacted properties: ApiKeySourceType, BinaryMediaTypes, Description, EndpointConfiguration, MinimumCompressionSize, Name, Policy).Unfortunately, this deletion by the importing of an OpenAPI specification, and then immediate recreation can introduce a race condition for private endpoints and their associated Route53 records.
Changes in this PR:
put_rest_api_mode
that will specify the mode of operations when importing an OpenAPI specification (create or update), this can be set tomerge
to prevent the OpenAPI spec from deleting existing endpoints which has been the root cause of a race condition.Closes #25640
For Community Discussion
Currently debating the need for a CustomDiff to suppress the new virtual attribute
put_rest_api_mode
as it defaults toooverwrite
. As written, when a user updates to this version of the provider and operates a plan or apply, Terraform will report a difference even though no HCL changes have been made:Decision
Output from acceptance testing: TBD