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

aws_db_cluster_snapshot: Provider produced inconsistent result after apply #15096

Closed
vdahmane opened this issue Sep 10, 2020 · 6 comments · Fixed by #15132
Closed

aws_db_cluster_snapshot: Provider produced inconsistent result after apply #15096

vdahmane opened this issue Sep 10, 2020 · 6 comments · Fixed by #15132
Labels
bug Addresses a defect in current functionality. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. service/rds Issues and PRs that pertain to the rds service.
Milestone

Comments

@vdahmane
Copy link

vdahmane commented Sep 10, 2020

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 other comments that do not add relevant new information or questions, 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 AWS Provider Version

2.67 and 3.x

Affected Resource(s)

aws_db_cluster_snapshot

Terraform Configuration Files

resource "aws_db_cluster_snapshot" "test" {
  db_cluster_identifier          =  "<arn of ressource>"
  db_cluster_snapshot_identifier = "Test"
}

Debug Output

Expected Behavior

Snapshot created without error messages like this:

Error: Provider produced inconsistent result after apply
When applying changes to aws_db_cluster_snapshot.externalbankuser_snapshot,
provider "registry.terraform.io/-/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.

Actual Behavior

I have this error message when i want to create aws_db_cluster_snapshot:

Error: Provider produced inconsistent result after apply
When applying changes to aws_db_cluster_snapshot.externalbankuser_snapshot,
provider "registry.terraform.io/-/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
@ghost ghost added the service/rds Issues and PRs that pertain to the rds service. label Sep 10, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Sep 10, 2020
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 10, 2020
@bflad
Copy link
Contributor

bflad commented Sep 10, 2020

Hi @vinced86 👋 Thank you for reporting this issue and sorry that you ran into trouble here.

We have seen problems with RDS in the past where the API may allow uppercase during creation without returning an error, but it is changed into lowercase behind the scenes, which generates this type of error in the Terraform AWS Provider resource. Looking at the RDS API Reference, it in fact does indicate this might be a problem and I was able to reproduce this by adjusting the TestAccAWSDBClusterSnapshot_basic acceptance test to use an uppercase snapshot identifier.

Does it work if you specify the db_cluster_snapshot_identifier with all lowercase? e.g.

resource "aws_db_cluster_snapshot" "test" {
  db_cluster_identifier          =  "<arn of ressource>"
  db_cluster_snapshot_identifier = "test"
}

To prevent this problem in the resource going forward and return an error during terraform plan, a ValidateFunc can be added to the db_cluster_snapshot_identifier attribute in that handles the API restrictions, e.g.

"db_cluster_snapshot_identifier": {
	Type:     schema.TypeString,
	Required: true,
	ForceNew: true,
	ValidateFunc: validation.All(
		validation.StringLenBetween(1, 63),
		validation.StringMatch(regexp.MustCompile(`^[0-9a-z-]+$`), "must contain only lowercase alphanumeric characters and hyphens"),
		validation.StringMatch(regexp.MustCompile(`^[a-z]`), "must begin with a lowercase letter"),
		validation.StringDoesNotMatch(regexp.MustCompile(`--`), "cannot contain two consecutive hyphens"),
		validation.StringDoesNotMatch(regexp.MustCompile(`-$`), "cannot end with a hyphen"),
	),
},

If you or anyone is interested in adding this, the source code is in the aws/resource_aws_db_cluster_snapshot.go file. 👍

@bflad bflad added the good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. label Sep 10, 2020
@angelabad
Copy link
Contributor

Thank you @bflad for the opportunity to learn

@bflad bflad added this to the v3.7.0 milestone Sep 14, 2020
@bflad
Copy link
Contributor

bflad commented Sep 14, 2020

Additional validation for the db_cluster_snapshot_identifier argument to ensure its lowercase has been merged and will release with version 3.7.0 of the Terraform AWS Provider, later this week. Thanks to @angelabad for the implementation. 👍

@vdahmane
Copy link
Author

Thanks a lot for your helps!

@ghost
Copy link

ghost commented Sep 17, 2020

This has been released in version 3.7.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 Oct 14, 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 as resolved and limited conversation to collaborators Oct 14, 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. good first issue Call to action for new contributors looking for a place to start. Smaller or straightforward issues. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
3 participants