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

service/rds: Initial support for RDS Aurora Global Databases #6861

Merged
merged 3 commits into from
Dec 19, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 14, 2018

Closes #6846

Changes:

  • resource/aws_rds_cluster: Allow global in engine_mode validation
  • resource/aws_rds_cluster: Add global_cluster_identifier argument
  • resource/aws_rds_cluster: Automatically remove cluster from global cluster on delete
  • New Resource: aws_rds_global_cluster
--- PASS: TestAccAWSRDSCluster_BacktrackWindow (185.53s)
--- PASS: TestAccAWSRDSCluster_backupsUpdate (206.64s)
--- PASS: TestAccAWSRDSCluster_basic (135.45s)
--- PASS: TestAccAWSRDSCluster_DeletionProtection (165.47s)
--- PASS: TestAccAWSRDSCluster_encrypted (126.42s)
--- PASS: TestAccAWSRDSCluster_EncryptedCrossRegionReplication (1609.46s)
--- PASS: TestAccAWSRDSCluster_EngineMode (344.98s)
--- PASS: TestAccAWSRDSCluster_EngineMode_Global (118.41s)
--- PASS: TestAccAWSRDSCluster_EngineMode_ParallelQuery (117.81s)
--- PASS: TestAccAWSRDSCluster_EngineVersion (122.85s)
--- PASS: TestAccAWSRDSCluster_EngineVersionWithPrimaryInstance (1022.02s)
--- PASS: TestAccAWSRDSCluster_generatedName (176.05s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier (125.53s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Add (132.58s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove (140.14s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Update (124.50s)
--- PASS: TestAccAWSRDSCluster_iamAuth (115.26s)
--- PASS: TestAccAWSRDSCluster_importBasic (116.22s)
--- PASS: TestAccAWSRDSCluster_kmsKey (144.50s)
--- PASS: TestAccAWSRDSCluster_missingUserNameCausesError (2.31s)
--- PASS: TestAccAWSRDSCluster_namePrefix (145.07s)
--- PASS: TestAccAWSRDSCluster_Port (252.80s)
--- PASS: TestAccAWSRDSCluster_s3Restore (1474.31s)
--- PASS: TestAccAWSRDSCluster_ScalingConfiguration (270.01s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier (438.26s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_DeletionProtection (374.71s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EncryptedRestore (331.91s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_ParallelQuery (353.25s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Provisioned (355.21s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Different (358.34s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Equal (394.42s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredBackupWindow (380.13s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredMaintenanceWindow (334.25s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_Tags (354.72s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds (255.20s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds_Tags (271.42s)
--- PASS: TestAccAWSRDSCluster_takeFinalSnapshot (93.01s)
--- PASS: TestAccAWSRDSCluster_updateCloudwatchLogsExports (158.10s)
--- PASS: TestAccAWSRDSCluster_updateIamRoles (122.85s)
--- PASS: TestAccAWSRDSCluster_updateTags (153.91s)

--- PASS: TestAccAWSRdsGlobalCluster_basic (14.24s)
--- PASS: TestAccAWSRdsGlobalCluster_DatabaseName (24.06s)
--- PASS: TestAccAWSRdsGlobalCluster_DeletionProtection (22.31s)
--- PASS: TestAccAWSRdsGlobalCluster_disappears (11.16s)
--- PASS: TestAccAWSRdsGlobalCluster_Engine_Aurora (14.41s)
--- PASS: TestAccAWSRdsGlobalCluster_EngineVersion_Aurora (14.24s)
--- PASS: TestAccAWSRdsGlobalCluster_StorageEncrypted (25.60s)

Changes:

* resource/aws_rds_cluster: Add `global_cluster_identifier` argument
* resource/aws_rds_cluster: Allow `global` in `engine_mode` validation
* resource/aws_rds_cluster: Automatically remove cluster from global cluster on delete
* New Resource: `aws_rds_global_cluster`

```
--- PASS: TestAccAWSRDSCluster_BacktrackWindow (185.53s)
--- PASS: TestAccAWSRDSCluster_backupsUpdate (206.64s)
--- PASS: TestAccAWSRDSCluster_basic (135.45s)
--- PASS: TestAccAWSRDSCluster_DeletionProtection (165.47s)
--- PASS: TestAccAWSRDSCluster_encrypted (126.42s)
--- PASS: TestAccAWSRDSCluster_EncryptedCrossRegionReplication (1609.46s)
--- PASS: TestAccAWSRDSCluster_EngineMode (344.98s)
--- PASS: TestAccAWSRDSCluster_EngineMode_Global (118.41s)
--- PASS: TestAccAWSRDSCluster_EngineMode_ParallelQuery (117.81s)
--- PASS: TestAccAWSRDSCluster_EngineVersion (122.85s)
--- PASS: TestAccAWSRDSCluster_EngineVersionWithPrimaryInstance (1022.02s)
--- PASS: TestAccAWSRDSCluster_generatedName (176.05s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier (125.53s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Add (132.58s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove (140.14s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Update (124.50s)
--- PASS: TestAccAWSRDSCluster_iamAuth (115.26s)
--- PASS: TestAccAWSRDSCluster_importBasic (116.22s)
--- PASS: TestAccAWSRDSCluster_kmsKey (144.50s)
--- PASS: TestAccAWSRDSCluster_missingUserNameCausesError (2.31s)
--- PASS: TestAccAWSRDSCluster_namePrefix (145.07s)
--- PASS: TestAccAWSRDSCluster_Port (252.80s)
--- PASS: TestAccAWSRDSCluster_s3Restore (1474.31s)
--- PASS: TestAccAWSRDSCluster_ScalingConfiguration (270.01s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier (438.26s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_DeletionProtection (374.71s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EncryptedRestore (331.91s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_ParallelQuery (353.25s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineMode_Provisioned (355.21s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Different (358.34s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_EngineVersion_Equal (394.42s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredBackupWindow (380.13s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_PreferredMaintenanceWindow (334.25s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_Tags (354.72s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds (255.20s)
--- PASS: TestAccAWSRDSCluster_SnapshotIdentifier_VpcSecurityGroupIds_Tags (271.42s)
--- PASS: TestAccAWSRDSCluster_takeFinalSnapshot (93.01s)
--- PASS: TestAccAWSRDSCluster_updateCloudwatchLogsExports (158.10s)
--- PASS: TestAccAWSRDSCluster_updateIamRoles (122.85s)
--- PASS: TestAccAWSRDSCluster_updateTags (153.91s)

--- PASS: TestAccAWSRdsGlobalCluster_basic (14.24s)
--- PASS: TestAccAWSRdsGlobalCluster_DatabaseName (24.06s)
--- PASS: TestAccAWSRdsGlobalCluster_DeletionProtection (22.31s)
--- PASS: TestAccAWSRdsGlobalCluster_disappears (11.16s)
--- PASS: TestAccAWSRdsGlobalCluster_Engine_Aurora (14.41s)
--- PASS: TestAccAWSRdsGlobalCluster_EngineVersion_Aurora (14.24s)
--- PASS: TestAccAWSRdsGlobalCluster_StorageEncrypted (25.60s)
```
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. service/rds Issues and PRs that pertain to the rds service. labels Dec 14, 2018
@bflad bflad requested a review from a team December 14, 2018 22:12
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 14, 2018
Copy link
Member

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM with some minor comments

aws/resource_aws_rds_cluster.go Outdated Show resolved Hide resolved
// Automatically remove from global cluster to bypass this error on deletion:
// InvalidDBClusterStateFault: This cluster is a part of a global cluster, please remove it from globalcluster first
if d.Get("global_cluster_identifier").(string) != "" {
input := &rds.RemoveFromGlobalClusterInput{
Copy link
Member

Choose a reason for hiding this comment

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

Since this same chunk of code is used in update, I'd suggest having it in it's own function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error handling is slightly different. 😄 I'm not sure if the indirection is worthwhile to fill in a two value struct, print a log line, and call the API, but we can certainly discuss this out of band! 👍

Copy link
Member

Choose a reason for hiding this comment

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

That's good with me!

Type: schema.TypeString,
Computed: true,
},
"source_db_cluster_identifier": {
Copy link
Member

Choose a reason for hiding this comment

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

I don't see this being used anywhere. Should we remove it or was it missed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good find and probably something I should've mentioned in the commit message/PR comment!

The RDS API gives you this second option for creating Global Clusters, based on an existing Cluster with global engine mode, instead of creating an "empty" Global Cluster. I think there were two reasons for omitting this to start.

When playing with this, the workflow wound up being very tedious because of operation ordering requirements within the RDS API and Terraform references. If I recall correctly, since the Cluster becomes a child of the Global Cluster in the dependency graph and Global Clusters, it wasn't easy to setup the resources to properly destroy. I may have inadvertently fixed this issue with the aws_rds_cluster resource Delete function update though. 😅

The other workflow issue is that engine mode cannot be currently updated for existing Clusters, so essentially you have to create new Clusters anyways to get Global Cluster support. I didn't think we needed to introduce all the complexity of supporting both creation methods initially, since operators can just adjust their initial Global Cluster configuration to match our supported workflow. I may have missed something in my thinking there though.

TL;DR I'll remove this attribute for now since its not used. If there are use cases that require it, we can add it (and all its complexity) later. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that I'm thinking about it more -- it was that because of the referencing (Global Cluster being dependent on Cluster), we'd try to destroy the Global Cluster first and it would complain that it still had members. We'd have to introduce a flag in aws_rds_global_cluster to allow you to force remove all members first. Not unsurmountable, but definitely additional complexity which we might not need.

Copy link
Member

Choose a reason for hiding this comment

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

Ouch, that extra flag seems tricky but I'm totally onboard with seeing this come in later if it's requested.

@bflad bflad added this to the v1.53.0 milestone Dec 19, 2018
@bflad
Copy link
Contributor Author

bflad commented Dec 19, 2018

TravisCI is green and re-verified the acceptance testing around the adjusted conditional, merging!

--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Update (118.41s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Add (125.06s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove (141.67s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier (166.14s)

@bflad bflad merged commit 659b02d into master Dec 19, 2018
@bflad bflad deleted the f-aws_rds_global_cluster branch December 19, 2018 17:31
bflad added a commit that referenced this pull request Dec 19, 2018
@bflad
Copy link
Contributor Author

bflad commented Dec 20, 2018

This has been released in version 1.53.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 1, 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 Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/rds Issues and PRs that pertain to the rds service. size/XXL 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
Development

Successfully merging this pull request may close these issues.

Feature Request: Add engine mode for global database to aws_rds_cluster
2 participants