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

module.networking.aws_default_route_table Error: Provider produced inconsistent result after apply #9009

Closed
mariaiano opened this issue Jun 16, 2019 · 10 comments · Fixed by #10981
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@mariaiano
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.2

  • provider.aws v2.15.0

Affected Resource(s)

  • aws_default_route_table

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

https://drive.google.com/open?id=1V0bn0OpZ8jrLKmml6XYUSSk7gQz8bxAN

Debug Output

https://drive.google.com/open?id=17udS9g1dBo3uI-IhkI2tr9Nbz_9B0UEr

Panic Output

Expected Behavior

module.networking.aws_default_route_table.dio_private_rt should have been created.

Actual Behavior

Instead I got this error:

Error: Provider produced inconsistent result after apply

When applying changes to
module.networking.aws_default_route_table.dio_private_rt, 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.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

  • #0000
@aeschright aeschright added the needs-triage Waiting for first response or review from a maintainer. label Jun 19, 2019
@aeschright aeschright added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jul 3, 2019
@mariaiano
Copy link
Author

I wonder why there aren't more people reporting this. Is there some workaround I'm missing?

@FernandoMiguel
Copy link
Contributor

@mariaiano i get this all the time :(
aws_cloudwatch_log_stream.log-stream, provider "aws" produced an unexpected new value for was present, but now absent.

@tiny-dancer
Copy link
Contributor

we're seeing this as well, starting to wrap TF in retries.

When applying changes to aws_vpc_endpoint_route_table_association.db_s3[1], provider "aws" produced an unexpected new value for was present, but now absent

@hotdawg789
Copy link

hotdawg789 commented Sep 9, 2019

Similar response with provider "aws" (hashicorp/aws) 2.25.0.

Error: Provider produced inconsistent result after apply

When applying changes to
aws_vpc_endpoint_route_table_association.pub_rancher_us-east-1a, 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.

@jayalane
Copy link

I think most people don't use default route table, perhaps because of this. The extra route tables (one default, one made by terraform) is confusing but functional.

@jayalane
Copy link

Ah, I have it: if you specify the VPC this way:

default_route_table_id = aws_vpc.whatever_vpc.id

You get that (which will happen if change aws_route_table to default_route table and then change the key from vpc_id but not the value).

You want

default_route_table_id = aws_vpc.whatever_vpc.default_route_table.id

@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 22, 2019
@bflad
Copy link
Contributor

bflad commented Nov 22, 2019

Hi folks 👋 Sorry you are running into this. Please note I've marked this issue as a bug, but we would prefer to capture each different Terraform resource reporting this error in separate bug reports. Each Terraform resource that hits this error will be due to different code and API behaviors. We are going to treat this report just for the original report of the aws_default_route_table resource.

The errant code can be found here: https://github.com/terraform-providers/terraform-provider-aws/blob/101295fdf4b62139d82808d43fd04d84bd1bb435/aws/resource_aws_default_route_table.go#L112-L116

In the Create function for the resource, we are returning an empty resource when no default route table is found where we should instead error in this scenario. The error message we can return can be much more helpful to the operator. 👍

I'll submit the fix for this shortly.

bflad added a commit that referenced this issue Nov 22, 2019
…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 this to the v2.40.0 milestone Nov 25, 2019
bflad added a commit that referenced this issue Nov 25, 2019
…ehavior when Default Route Table is missing (#10981)

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
Copy link
Contributor

bflad commented Nov 25, 2019

The adjustment of the aws_default_route_table resource to return a more helpful error in this scenario has been merged and will release with version 2.40.0 of the Terraform AWS Provider this week. If you are seeing the Provider produced inconsistent result after apply with other resources (or this resource after this fix is released) please submit a new bug report following the issue template for further triage. Thanks.

@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.
Projects
None yet
7 participants