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_default_route_table: Fixes for creation and recreation behavior when Default Route Table is missing #10981

Merged
merged 1 commit into from
Nov 25, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Nov 22, 2019

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes #398
Closes #3551
Closes #9009

Release note for CHANGELOG:

* resource/aws_default_route_table: Return helpful not found error on resource creation instead of generic `Provider produced inconsistent result after apply` error when given invalid `default_route_table_id` argument value
* resource/aws_default_route_table: Propose resource recreation for missing Default Route Table on refresh instead of returning an error

Previously on creation, if the Default Route Table was incorrectly configured or non-existent, the resource would unexpectedly attempt to remove itself from the Terraform state and propose recreation immediately. Prior to Terraform 0.12, this behavior was errantly acceptable. In Terraform 0.12, resources are required to return Terraform state about themselves during creation or throw an error explaining why the creation failed.

Previously on read, if the Default Route Table was missing (e.g. due to the VPC being deleted outside Terraform), the resource would return an error and require operators to manually perform a terraform state rm command instead of proposing resource recreation.

Output from new acceptance testing before code updates:

--- FAIL: TestAccAWSDefaultRouteTable_basic (20.02s)
    testing.go:628: Step 0, expected error:

        errors during apply: Provider produced inconsistent result after apply: When applying changes to aws_default_route_table.foo, provider "aws" produced an unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own issue tracker.

        To match:

        TBD

--- FAIL: TestAccAWSDefaultRouteTable_disappears_Vpc (20.27s)
    testing.go:635: Step 0 error: errors during follow-up refresh:

        Error: Default Route table not found

    testing.go:696: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during refresh: Default Route table not found

        State: <nil>

Output from acceptance testing after code updates:

--- PASS: TestAccAWSDefaultRouteTable_disappears_Vpc (20.46s)
--- PASS: TestAccAWSDefaultRouteTable_basic (40.99s)
--- PASS: TestAccAWSDefaultRouteTable_vpc_endpoint (49.71s)
--- PASS: TestAccAWSDefaultRouteTable_swap (73.89s)
--- PASS: TestAccAWSDefaultRouteTable_Route (87.09s)
--- PASS: TestAccAWSDefaultRouteTable_Route_TransitGatewayID (374.87s)

…ehavior when Default Route Table is missing

Reference: #398
Reference: #3551
Reference: #9009

Previously on creation, if the Default Route Table was incorrectly configured or non-existent, the resource would unexpectedly attempt to remove itself from the Terraform state and propose recreation immediately. Prior to Terraform 0.12, this behavior was errantly acceptable. In Terraform 0.12, resources are required to return Terraform state about themselves during creation or throw an error explaining why the creation failed.

Previously on read, if the Default Route Table was missing (e.g. due to the VPC being deleted outside Terraform), the resource would return an error and require operators to manually perform a `terraform state rm` command instead of proposing resource recreation.

Output from new acceptance testing before code updates:

```
--- FAIL: TestAccAWSDefaultRouteTable_basic (20.02s)
    testing.go:628: Step 0, expected error:

        errors during apply: Provider produced inconsistent result after apply: When applying changes to aws_default_route_table.foo, provider "aws" produced an unexpected new value for was present, but now absent.

        This is a bug in the provider, which should be reported in the provider's own issue tracker.

        To match:

        TBD

--- FAIL: TestAccAWSDefaultRouteTable_disappears_Vpc (20.27s)
    testing.go:635: Step 0 error: errors during follow-up refresh:

        Error: Default Route table not found

    testing.go:696: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during refresh: Default Route table not found

        State: <nil>
```

Output from acceptance testing after code updates:

```
--- PASS: TestAccAWSDefaultRouteTable_disappears_Vpc (20.46s)
--- PASS: TestAccAWSDefaultRouteTable_basic (40.99s)
--- PASS: TestAccAWSDefaultRouteTable_vpc_endpoint (49.71s)
--- PASS: TestAccAWSDefaultRouteTable_swap (73.89s)
--- PASS: TestAccAWSDefaultRouteTable_Route (87.09s)
--- PASS: TestAccAWSDefaultRouteTable_Route_TransitGatewayID (374.87s)
```
@bflad bflad added the bug Addresses a defect in current functionality. label Nov 22, 2019
@bflad bflad requested a review from a team November 22, 2019 20:45
@ghost ghost added size/M Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Nov 22, 2019
@aeschright aeschright removed the needs-triage Waiting for first response or review from a maintainer. label Nov 22, 2019
@aeschright aeschright self-assigned this Nov 22, 2019
Copy link
Contributor

@aeschright aeschright left a comment

Choose a reason for hiding this comment

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

Looks good!

--- PASS: TestAccAWSDefaultRouteTable_disappears_Vpc (14.69s)
--- PASS: TestAccAWSDefaultRouteTable_basic (28.14s)
--- PASS: TestAccAWSDefaultRouteTable_vpc_endpoint (34.15s)
--- PASS: TestAccAWSDefaultRouteTable_swap (44.02s)
--- PASS: TestAccAWSDefaultRouteTable_Route (53.77s)
--- PASS: TestAccAWSDefaultRouteTable_Route_TransitGatewayID (333.32s)

@bflad bflad added this to the v2.40.0 milestone Nov 25, 2019
@bflad bflad merged commit e60923b into master Nov 25, 2019
@bflad bflad deleted the b-aws_default_route_table-not-found branch November 25, 2019 16:04
bflad added a commit that referenced this pull request Nov 25, 2019
@ghost
Copy link

ghost commented Nov 27, 2019

This has been released in version 2.40.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 Mar 29, 2020

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 Mar 29, 2020
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/ec2 Issues and PRs that pertain to the ec2 service. size/M 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
2 participants