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

resource/aws_api_gateway_rest_api: Fix disable_execute_api_endpoint and endpoint_configuration vpc_endpoint_ids handling with OpenAPI specification import (body argument) #17209

Merged

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 21, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #13841

Release note for CHANGELOG:

* resource/aws_api_gateway_rest_api: Fix `disable_execute_api_endpoint` and `endpoint_configuration` `vpc_endpoint_ids` handling with OpenAPI specification import (`body` argument)

Before code updates, these new acceptance tests show how the Terraform configuration value would not be applied if an OpenAPI specification was imported:

=== CONT  TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody
    resource_aws_api_gateway_rest_api_test.go:847: Step 1/4 error: Check failed: 1 error occurred:
        	* Check 2/2 error: aws_api_gateway_rest_api.test: Attribute 'disable_execute_api_endpoint' expected "false", got "true"

--- FAIL: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody (10.30s)

=== CONT  TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody
    resource_aws_api_gateway_rest_api_test.go:369: Step 1/2 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout

        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # aws_api_gateway_rest_api.test will be updated in-place
          ~ resource "aws_api_gateway_rest_api" "test" {
                id                           = "m9ajz6izjl"
                name                         = "tf-acc-test-6139822644948363723"
                tags                         = {}
                # (9 unchanged attributes hidden)

              ~ endpoint_configuration {
                  ~ vpc_endpoint_ids = [
                      + "vpce-0ba0b61be45886a6f",
                      - "vpce-0ee1a2ccd6af8f011",
                    ]
                    # (1 unchanged attribute hidden)
                }
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody (190.95s)

Before code updates, these new acceptance tests show how the Terraform resource would report an unexpected difference for missing configurations that were imported by the OpenAPI specification:

=== CONT  TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody
    resource_aws_api_gateway_rest_api_test.go:890: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:

        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # aws_api_gateway_rest_api.test will be updated in-place
          ~ resource "aws_api_gateway_rest_api" "test" {
              ~ disable_execute_api_endpoint = true -> false
                id                           = "c2t6iky152"
                name                         = "tf-acc-test-8877194198775672292"
                # (8 unchanged attributes hidden)

                # (1 unchanged block hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody (11.03s)

=== CONT  TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody
    resource_aws_api_gateway_rest_api_test.go:415: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:

        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # aws_api_gateway_rest_api.test will be updated in-place
          ~ resource "aws_api_gateway_rest_api" "test" {
                id                           = "adeg2zcky2"
                name                         = "tf-acc-test-7848512816247428885"
                # (9 unchanged attributes hidden)

              ~ endpoint_configuration {
                  ~ vpc_endpoint_ids = [
                      - "vpce-0653ca468e4c6ba4a",
                    ]
                    # (1 unchanged attribute hidden)
                }
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody (150.67s)

Output from acceptance testing:

--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource (30.53s)
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource_OverrideBody (37.78s)
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource_SetByBody (15.25s)
--- PASS: TestAccAWSAPIGatewayRestApi_basic (669.92s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes (34.56s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_OverrideBody (34.23s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_SetByBody (514.96s)
--- PASS: TestAccAWSAPIGatewayRestApi_Body (38.01s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description (23.87s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description_OverrideBody (60.58s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description_SetByBody (92.79s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint (3442.94s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody (2292.47s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody (1083.96s)
--- PASS: TestAccAWSAPIGatewayRestApi_disappears (529.45s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration (1034.47s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_Private (15.42s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds (330.11s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody (205.73s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody (159.85s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize (39.32s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_OverrideBody (1278.64s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_SetByBody (753.00s)
--- PASS: TestAccAWSAPIGatewayRestApi_Name_OverrideBody (2212.45s)
--- PASS: TestAccAWSAPIGatewayRestApi_Parameters (948.67s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy (28.00s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy_OverrideBody (80.78s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy_SetByBody (1967.74s)
--- PASS: TestAccAWSAPIGatewayRestApi_tags (1413.12s)

…nd endpoint_configuration vpc_endpoint_ids handling with OpenAPI specification import (body argument)

Reference: #13841

Before code updates, these new acceptance tests show how the Terraform configuration value would not be applied if an OpenAPI specification was imported:

```
=== CONT  TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody
    resource_aws_api_gateway_rest_api_test.go:847: Step 1/4 error: Check failed: 1 error occurred:
        	* Check 2/2 error: aws_api_gateway_rest_api.test: Attribute 'disable_execute_api_endpoint' expected "false", got "true"

--- FAIL: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody (10.30s)

=== CONT  TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody
    resource_aws_api_gateway_rest_api_test.go:369: Step 1/2 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout

        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # aws_api_gateway_rest_api.test will be updated in-place
          ~ resource "aws_api_gateway_rest_api" "test" {
                id                           = "m9ajz6izjl"
                name                         = "tf-acc-test-6139822644948363723"
                tags                         = {}
                # (9 unchanged attributes hidden)

              ~ endpoint_configuration {
                  ~ vpc_endpoint_ids = [
                      + "vpce-0ba0b61be45886a6f",
                      - "vpce-0ee1a2ccd6af8f011",
                    ]
                    # (1 unchanged attribute hidden)
                }
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody (190.95s)
```

Before code updates, these new acceptance tests show how the Terraform resource would report an unexpected difference for missing configurations that were imported by the OpenAPI specification:

```
=== CONT  TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody
    resource_aws_api_gateway_rest_api_test.go:890: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:

        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # aws_api_gateway_rest_api.test will be updated in-place
          ~ resource "aws_api_gateway_rest_api" "test" {
              ~ disable_execute_api_endpoint = true -> false
                id                           = "c2t6iky152"
                name                         = "tf-acc-test-8877194198775672292"
                # (8 unchanged attributes hidden)

                # (1 unchanged block hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody (11.03s)

=== CONT  TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody
    resource_aws_api_gateway_rest_api_test.go:415: Step 1/2 error: After applying this test step, the plan was not empty.
        stdout:

        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
          ~ update in-place

        Terraform will perform the following actions:

          # aws_api_gateway_rest_api.test will be updated in-place
          ~ resource "aws_api_gateway_rest_api" "test" {
                id                           = "adeg2zcky2"
                name                         = "tf-acc-test-7848512816247428885"
                # (9 unchanged attributes hidden)

              ~ endpoint_configuration {
                  ~ vpc_endpoint_ids = [
                      - "vpce-0653ca468e4c6ba4a",
                    ]
                    # (1 unchanged attribute hidden)
                }
            }

        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody (150.67s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource (30.53s)
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource_OverrideBody (37.78s)
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource_SetByBody (15.25s)
--- PASS: TestAccAWSAPIGatewayRestApi_basic (669.92s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes (34.56s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_OverrideBody (34.23s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_SetByBody (514.96s)
--- PASS: TestAccAWSAPIGatewayRestApi_Body (38.01s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description (23.87s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description_OverrideBody (60.58s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description_SetByBody (92.79s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint (3442.94s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody (2292.47s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody (1083.96s)
--- PASS: TestAccAWSAPIGatewayRestApi_disappears (529.45s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration (1034.47s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_Private (15.42s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds (330.11s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody (205.73s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody (159.85s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize (39.32s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_OverrideBody (1278.64s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_SetByBody (753.00s)
--- PASS: TestAccAWSAPIGatewayRestApi_Name_OverrideBody (2212.45s)
--- PASS: TestAccAWSAPIGatewayRestApi_Parameters (948.67s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy (28.00s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy_OverrideBody (80.78s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy_SetByBody (1967.74s)
--- PASS: TestAccAWSAPIGatewayRestApi_tags (1413.12s)
```
@bflad bflad added the bug Addresses a defect in current functionality. label Jan 21, 2021
@bflad bflad requested a review from a team as a code owner January 21, 2021 05:35
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/apigateway Issues and PRs that pertain to the apigateway service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 21, 2021
@YakDriver YakDriver self-assigned this Jan 21, 2021
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commercial:

--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource_OverrideBody (403.24s)
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource_SetByBody (587.39s)
--- PASS: TestAccAWSAPIGatewayRestApi_basic (17.86s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes (205.50s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_OverrideBody (122.93s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description (877.06s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description_OverrideBody (634.31s)
--- PASS: TestAccAWSAPIGatewayRestApi_Description_SetByBody (599.29s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint (877.22s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody (149.52s)
--- PASS: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody (483.50s)
--- PASS: TestAccAWSAPIGatewayRestApi_disappears (218.26s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration (190.63s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_Private (49.42s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds (366.41s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody (242.17s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody (212.34s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize (941.24s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_OverrideBody (139.69s)
--- PASS: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_SetByBody (55.24s)
--- PASS: TestAccAWSAPIGatewayRestApi_Name_OverrideBody (114.05s)
--- PASS: TestAccAWSAPIGatewayRestApi_Parameters (267.21s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy (379.22s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy_OverrideBody (83.44s)
--- PASS: TestAccAWSAPIGatewayRestApi_Policy_SetByBody (233.85s)
--- PASS: TestAccAWSAPIGatewayRestApi_tags (472.42s)
--- PASS: TestAccAWSAPIGatewayRestApi_Body (1147.91s)
--- PASS: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_SetByBody (1148.37s)
--- PASS: TestAccAWSAPIGatewayRestApi_ApiKeySource (1209.28s)

GovCloud:

--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_Private (19.59s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds (351.65s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_OverrideBody (203.30s)
--- PASS: TestAccAWSAPIGatewayRestApi_EndpointConfiguration_VpcEndpointIds_SetByBody (163.71s)
--- SKIP: TestAccAWSAPIGatewayRestApi_ApiKeySource (0.01s)
--- SKIP: TestAccAWSAPIGatewayRestApi_ApiKeySource_OverrideBody (0.00s)
--- SKIP: TestAccAWSAPIGatewayRestApi_ApiKeySource_SetByBody (0.00s)
--- SKIP: TestAccAWSAPIGatewayRestApi_basic (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_OverrideBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_BinaryMediaTypes_SetByBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Body (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Description (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Description_OverrideBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Description_SetByBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_OverrideBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_DisableExecuteApiEndpoint_SetByBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_disappears (0.00s)
--- SKIP: TestAccAWSAPIGatewayRestApi_EndpointConfiguration (29.09s)
--- SKIP: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_OverrideBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_MinimumCompressionSize_SetByBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Name_OverrideBody (0.00s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Parameters (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Policy (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Policy_OverrideBody (0.00s)
--- SKIP: TestAccAWSAPIGatewayRestApi_Policy_SetByBody (1.30s)
--- SKIP: TestAccAWSAPIGatewayRestApi_tags (0.00s)

Comment on lines +1325 to +1326
disable_execute_api_endpoint = %[2]t
name = %[1]q
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disable_execute_api_endpoint = %[2]t
name = %[1]q
name = %[1]q
disable_execute_api_endpoint = %[2]t

Super nit

Copy link
Contributor Author

@bflad bflad Jan 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the newer test resource configurations should be alphabetical for human readability, it just so happens that there is also the potentially competing convention of rName always being the first fmt.Sprintf() parameter. 🙁 This should go away if/when a newer testing framework is available that works with Terraform variables instead. We could do that style of configuration now, but since we don't know the final design of that new framework, I would be hesitant to create yet another style of configuration in the meantime in case it does not align correctly with it.

@bflad bflad added this to the v3.25.0 milestone Jan 21, 2021
@bflad bflad merged commit 8dfc019 into master Jan 21, 2021
@bflad bflad deleted the b-aws_api_gateway_rest_api-endpoint_configuration-override branch January 21, 2021 19:54
bflad added a commit that referenced this pull request Jan 21, 2021
@ghost
Copy link

ghost commented Jan 22, 2021

This has been released in version 3.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 for triage. Thanks!

@ghost
Copy link

ghost commented Feb 21, 2021

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 as resolved and limited conversation to collaborators Feb 21, 2021
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. documentation Introduces or discusses updates to documentation. service/apigateway Issues and PRs that pertain to the apigateway service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_api_gateway_rest_api private API does not set VPC Endpoint association or policy until SECOND apply.
2 participants