-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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: Consolidate CreateDBCluster logic and prevent creation issue when global_cluster_identifier and replication_source_identifier are both configured #14490
Conversation
…nt creation issue when global_cluster_identifier and replication_source_identifier are both configured Reference: #13715 After adding new acceptance testing with previous resource logic: ``` TestAccAWSRDSCluster_GlobalClusterIdentifier_ReplicationSourceIdentifier: testing.go:684: Step 0 error: errors during apply: Error: error creating RDS cluster: InvalidDBClusterStateFault: Source cluster arn:aws:rds:us-west-2:--OMITTED--:cluster:tf-acc-test-728428284997379009-primary doesn't have binlogs enabled. status code: 400, request id: 36e4f744-9080-4a6c-adca-fb2fc660d66e ``` After consolidating `CreateDBCluster` logic (allowing both `global_cluster_identifier` and `replication_source_identifier` to be set in the same call): ``` TestAccAWSRDSCluster_GlobalClusterIdentifier_ReplicationSourceIdentifier: testing.go:684: Step 0 error: errors during apply: Error: error creating RDS cluster: InvalidParameterCombination: Value for replicationSourceIdentifier should not be specified for db cluster that is a member of global cluster status code: 400, request id: f8558f28-14d1-49b3-9d94-1a607b1b689d ``` Opt to conditionalize the creation handling for this situation rather than return an error for the conflicting arguments since the existing configuration may be prevalent and the end result is the same. Document `ignore_changes`. Output from acceptance testing (omitting failures from #14384): ``` --- PASS: TestAccAWSRDSCluster_AvailabilityZones (138.84s) --- PASS: TestAccAWSRDSCluster_BacktrackWindow (166.46s) --- PASS: TestAccAWSRDSCluster_backupsUpdate (161.00s) --- PASS: TestAccAWSRDSCluster_basic (143.12s) --- PASS: TestAccAWSRDSCluster_ClusterIdentifierPrefix (137.99s) --- PASS: TestAccAWSRDSCluster_copyTagsToSnapshot (205.95s) --- PASS: TestAccAWSRDSCluster_DbSubnetGroupName (159.06s) --- PASS: TestAccAWSRDSCluster_DeletionProtection (160.99s) --- PASS: TestAccAWSRDSCluster_EnabledCloudwatchLogsExports (341.44s) --- PASS: TestAccAWSRDSCluster_EnableHttpEndpoint (356.65s) --- PASS: TestAccAWSRDSCluster_encrypted (121.15s) --- PASS: TestAccAWSRDSCluster_EngineMode (432.72s) --- PASS: TestAccAWSRDSCluster_EngineMode_Global (139.87s) --- PASS: TestAccAWSRDSCluster_EngineMode_Multimaster (139.86s) --- PASS: TestAccAWSRDSCluster_EngineMode_ParallelQuery (137.74s) --- PASS: TestAccAWSRDSCluster_EngineVersion (425.30s) --- PASS: TestAccAWSRDSCluster_EngineVersionWithPrimaryInstance (1107.25s) --- PASS: TestAccAWSRDSCluster_generatedName (126.84s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global (189.88s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Add (163.70s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Remove (162.57s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Update (172.66s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Provisioned (157.23s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_PrimarySecondaryClusters (1768.71s) --- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_ReplicationSourceIdentifier (1747.31s) --- PASS: TestAccAWSRDSCluster_iamAuth (127.32s) --- PASS: TestAccAWSRDSCluster_kmsKey (161.41s) --- PASS: TestAccAWSRDSCluster_missingUserNameCausesError (4.87s) --- PASS: TestAccAWSRDSCluster_Port (253.12s) --- PASS: TestAccAWSRDSCluster_ScalingConfiguration (386.00s) --- PASS: TestAccAWSRDSCluster_ScalingConfiguration_DefaultMinCapacity (379.58s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier (371.73s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_DeletionProtection (409.17s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EncryptedRestore (358.98s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_ParallelQuery (439.76s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Provisioned (333.04s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Different (359.99s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Equal (337.24s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_MasterPassword (347.53s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_MasterUsername (381.60s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredBackupWindow (379.98s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredMaintenanceWindow (363.89s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_Tags (381.05s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds (362.04s) --- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds_Tags (369.15s) --- PASS: TestAccAWSRDSCluster_Tags (136.51s) --- PASS: TestAccAWSRDSCluster_takeFinalSnapshot (207.97s) --- PASS: TestAccAWSRDSCluster_updateIamRoles (180.35s) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀 -- just left a question related to the replication param
Output of acceptance tests (skipping the tech-debt tests):
--- PASS: TestAccAWSRDSClusterEndpoint_basic (1136.33s)
--- PASS: TestAccAWSRDSClusterInstance_CACertificateIdentifier (611.96s)
--- PASS: TestAccAWSRDSClusterInstance_CopyTagsToSnapshot (773.25s)
--- PASS: TestAccAWSRDSClusterInstance_MonitoringInterval (1282.14s)
--- PASS: TestAccAWSRDSClusterInstance_MonitoringRoleArn_EnabledToDisabled (1080.01s)
--- PASS: TestAccAWSRDSClusterInstance_MonitoringRoleArn_EnabledToRemoved (1050.34s)
--- PASS: TestAccAWSRDSClusterInstance_MonitoringRoleArn_RemovedToEnabled (909.83s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraMysql1 (849.99s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraMysql2 (812.57s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsEnabled_AuroraPostgresql (874.07s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsKmsKeyId_AuroraMysql1 (830.69s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsKmsKeyId_AuroraMysql1_DefaultKeyToCustomKey (902.21s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsKmsKeyId_AuroraMysql2 (794.21s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsKmsKeyId_AuroraMysql2_DefaultKeyToCustomKey (796.21s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsKmsKeyId_AuroraPostgresql (757.70s)
--- PASS: TestAccAWSRDSClusterInstance_PerformanceInsightsKmsKeyId_AuroraPostgresql_DefaultKeyToCustomKey (748.22s)
--- PASS: TestAccAWSRDSClusterInstance_PubliclyAccessible (797.95s)
--- PASS: TestAccAWSRDSClusterInstance_az (894.93s)
--- PASS: TestAccAWSRDSClusterInstance_basic (1490.65s)
--- PASS: TestAccAWSRDSClusterInstance_disappears (753.36s)
--- PASS: TestAccAWSRDSClusterInstance_generatedName (746.02s)
--- PASS: TestAccAWSRDSClusterInstance_isAlreadyBeingDeleted (709.99s)
--- PASS: TestAccAWSRDSClusterInstance_kmsKey (731.88s)
--- PASS: TestAccAWSRDSClusterInstance_namePrefix (673.98s)
--- PASS: TestAccAWSRDSCluster_AvailabilityZones (123.32s)
--- PASS: TestAccAWSRDSCluster_BacktrackWindow (168.96s)
--- PASS: TestAccAWSRDSCluster_ClusterIdentifierPrefix (132.07s)
--- PASS: TestAccAWSRDSCluster_DbSubnetGroupName (128.38s)
--- PASS: TestAccAWSRDSCluster_DeletionProtection (169.58s)
--- PASS: TestAccAWSRDSCluster_EnableHttpEndpoint (359.41s)
--- PASS: TestAccAWSRDSCluster_EnabledCloudwatchLogsExports (323.88s)
--- PASS: TestAccAWSRDSCluster_EngineMode (433.92s)
--- PASS: TestAccAWSRDSCluster_EngineMode_Global (170.52s)
--- PASS: TestAccAWSRDSCluster_EngineMode_Multimaster (140.72s)
--- PASS: TestAccAWSRDSCluster_EngineMode_ParallelQuery (152.82s)
--- PASS: TestAccAWSRDSCluster_EngineVersion (415.71s)
--- PASS: TestAccAWSRDSCluster_EngineVersionWithPrimaryInstance (1711.31s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global (168.62s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Add (168.14s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Remove (163.73s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Update (171.14s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Provisioned (126.50s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_PrimarySecondaryClusters (1775.28s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_ReplicationSourceIdentifier (1917.42s)
--- PASS: TestAccAWSRDSCluster_Port (270.75s)
--- PASS: TestAccAWSRDSCluster_ScalingConfiguration (343.50s)
--- PASS: TestAccAWSRDSCluster_ScalingConfiguration_DefaultMinCapacity (305.31s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier (353.88s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_DeletionProtection (398.91s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EncryptedRestore (351.41s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_ParallelQuery (420.09s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Provisioned (363.53s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Different (422.54s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Equal (399.31s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_MasterPassword (343.16s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_MasterUsername (332.33s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredMaintenanceWindow (340.92s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_Tags (336.79s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds (336.02s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds_Tags (342.05s)
--- PASS: TestAccAWSRDSCluster_Tags (139.17s)
--- PASS: TestAccAWSRDSCluster_backupsUpdate (173.64s)
--- PASS: TestAccAWSRDSCluster_basic (122.28s)
--- PASS: TestAccAWSRDSCluster_copyTagsToSnapshot (217.98s)
--- PASS: TestAccAWSRDSCluster_encrypted (133.17s)
--- PASS: TestAccAWSRDSCluster_generatedName (136.78s)
--- PASS: TestAccAWSRDSCluster_iamAuth (123.32s)
--- PASS: TestAccAWSRDSCluster_kmsKey (135.48s)
--- PASS: TestAccAWSRDSCluster_missingUserNameCausesError (4.66s)
--- PASS: TestAccAWSRDSCluster_takeFinalSnapshot (153.56s)
--- PASS: TestAccAWSRDSCluster_updateIamRoles (171.52s)
@@ -123,7 +123,7 @@ The following arguments are supported: | |||
* `port` - (Optional) The port on which the DB accepts connections | |||
* `preferred_backup_window` - (Optional) The daily time range during which automated backups are created if automated backups are enabled using the BackupRetentionPeriod parameter.Time in UTC. Default: A 30-minute window selected at random from an 8-hour block of time per region. e.g. 04:00-09:00 | |||
* `preferred_maintenance_window` - (Optional) The weekly time range during which system maintenance can occur, in (UTC) e.g. wed:04:00-wed:04:30 | |||
* `replication_source_identifier` - (Optional) ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. | |||
* `replication_source_identifier` - (Optional) ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica. If DB Cluster is part of a Global Cluster, use the [`lifecycle` configuration block `ignore_changes` argument](/docs/configuration/resources.html#ignore_changes) to prevent Terraform from showing differences for this argument instead of configuring this value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you come across the behavior where setting this argument as Computed
would cause the "secondary" cluster to remain even after successfully destroying its instance and the other clusters, but no error would be returned? curious if its different than the case of the global_cluster_identifier
, where having that field as Computed
doesn't allow deletion from the global_cluster at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crux of the issue with global_cluster_identifier
was that it was essentially not possible to perform a configuration update to remove the cluster from the Global Cluster while also keeping the Global Cluster around. There's small writeup of the problem with Computed: true
not even allowing operators to set the value to ""
to remove things in the #14487 PR description. I tried fiddling with it last night for a few hours without luck, since Terraform never invokes the resource update function even though it should.
I do not believe there is a covering test for removing replication_source_identifier
at the moment (to promote a secondary cluster to standalone) like there is TestAccAWSRDSCluster_GlobalClusterIdentifier_EngineMode_Global_Remove
🙁 It'd be awesome to add one though! It'd be related to #6749.
This has been released in version 3.1.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! |
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! |
Community Note
Closes #13715
Release note for CHANGELOG:
After adding new acceptance testing with previous resource logic:
After consolidating
CreateDBCluster
logic (allowing bothglobal_cluster_identifier
andreplication_source_identifier
to be set in the same call):Opt to conditionalize the creation handling for this situation rather than return an error for the conflicting arguments since the existing configuration may be prevalent and the end result is the same. Document
ignore_changes
.Output from acceptance testing (omitting failures from #14384):