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_rds_cluster: Terraform 0.14 ignore_changes Handling with global_cluster_identifier #15645

Closed
bflad opened this issue Oct 14, 2020 · 3 comments
Assignees
Labels
service/rds Issues and PRs that pertain to the rds service. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Comments

@bflad
Copy link
Contributor

bflad commented Oct 14, 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

Description

Future versions of Terraform CLI, starting with 0.14, are more sensitive to how the lifecycle configuration block ignore_changes argument is applied. Directionally, Terraform's core logic has been moving towards being more explicit about what Terraform Providers can and cannot suggest towards having configurations differ from the final applied state. These differences typically are what cause subtle bugs in core's handling across its whole feature set or represent situations where a generated plan may not exactly match the applied intention of a configuration.

In our Terraform 0.14.0-alpha20201007 testing of the provider, this failure is present:

=== CONT  TestAccAWSRdsGlobalCluster_SourceDbClusterIdentifier
TestAccAWSRdsGlobalCluster_SourceDbClusterIdentifier: resource_aws_rds_global_cluster_test.go:305: Step 1/2 error: Error running pre-apply refresh:
Error: Cannot ignore argument not set in the configuration
on config006164243/terraform_plugin_test.tf line 13, in resource "aws_rds_cluster" "test":
13:     ignore_changes = [global_cluster_identifier]
The ignore_changes argument is not set in the configuration.
The ignore_changes mechanism only applies to changes within the configuration,
and must be used with arguments set in the configuration and not computed by
the provider.
--- FAIL: TestAccAWSRdsGlobalCluster_SourceDbClusterIdentifier (3.06s)

This attribute is used for creating an Aurora global cluster member on aws_rds_cluster resource creation or as in the case of this test, has the value of its global cluster when its used as the source of creating an Aurora global cluster. Given the latter situation but the possibility for the first situation if its value was defined in the configuration, the Terraform resource must mark this attribute with Computed: true so it can be properly set by the provider without a configuration (and ignore_changes omitted). This effectively disables drift detection when not configured, which should be documented during the resource update.

However, potentially unlike #15643, marking the attribute as Computed: true could introduce a new problem with the resource deletion as noted in the original implementation description:

Attempting to add Computed: true to the aws_rds_cluster resource to match the Terraform core contract that the value will be potentially filled in by the API outside of configuration prevents practitioners from being able to successfully remove a DB Cluster from the Global Cluster, even with setting the value to "". This is likely a bug in the Terraform Plugin SDK, but its behavior has likely been present for so long that attempting to fix it would present its own major problems for providers. For now, just document ignore_changes as the implementation.

Affected Resource(s)

  • aws_rds_cluster

Potential Terraform Configuration

resource "aws_rds_cluster" "test" {
  cluster_identifier  = %[1]q
  engine              = "aurora-postgresql"
  engine_version      = "10.11" # Minimum supported version for Global Clusters
  master_password     = "mustbeeightcharacters"
  master_username     = "test"
  skip_final_snapshot = true

  # This configuration needs to be removed below with passing tests
  lifecycle {
    ignore_changes = [global_cluster_identifier]
  }
}

resource "aws_rds_global_cluster" "test" {
  force_destroy                = true
  global_cluster_identifier    = %[1]q
  source_db_cluster_identifier = aws_rds_cluster.test.arn
}

References

@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/rds Issues and PRs that pertain to the rds service. technical-debt Addresses areas of the codebase that need refactoring or redesign. terraform-0.14 labels Oct 14, 2020
@bflad bflad self-assigned this Oct 30, 2020
@bflad
Copy link
Contributor Author

bflad commented Oct 30, 2020

Will start on this after test fixes in #15938 have been sorted.

@bflad
Copy link
Contributor Author

bflad commented Nov 30, 2020

The acceptance test that previously failed in the early alpha build is passing with rc1, so my hunch here is that nothing will be required to do before the Terraform 0.14 release with the resource.

@bflad bflad closed this as completed Nov 30, 2020
@ghost
Copy link

ghost commented Dec 31, 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 Dec 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/rds Issues and PRs that pertain to the rds service. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

No branches or pull requests

1 participant