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

Fixing global rds by allowing for optional parameters on cluster #7213

Merged
merged 2 commits into from
Feb 22, 2019

Conversation

bculberson
Copy link
Contributor

@bculberson bculberson commented Jan 19, 2019

Fixes #7212 and #7020

TBD: Add global acc test

Changes proposed in this pull request:

  • Change 1
    Allow username and password to be optional when using a global cluster identifier
  • Change 2
    Allow source region and global cluster identifier to be set for secondary region to come online

Output from acceptance testing:

make testacc TESTARGS='-run=TestAccAWSRDSCluster_GlobalClusterIdentifier'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSRDSCluster_GlobalClusterIdentifier -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSRDSCluster_GlobalClusterIdentifier
=== PAUSE TestAccAWSRDSCluster_GlobalClusterIdentifier
=== RUN   TestAccAWSRDSCluster_GlobalClusterIdentifier_Add
=== PAUSE TestAccAWSRDSCluster_GlobalClusterIdentifier_Add
=== RUN   TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove
=== PAUSE TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove
=== RUN   TestAccAWSRDSCluster_GlobalClusterIdentifier_Update
=== PAUSE TestAccAWSRDSCluster_GlobalClusterIdentifier_Update
=== CONT  TestAccAWSRDSCluster_GlobalClusterIdentifier
=== CONT  TestAccAWSRDSCluster_GlobalClusterIdentifier_Update
=== CONT  TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove
=== CONT  TestAccAWSRDSCluster_GlobalClusterIdentifier_Add
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Add (218.57s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Update (218.81s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier (243.67s)
--- PASS: TestAccAWSRDSCluster_GlobalClusterIdentifier_Remove (250.19s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	250.852s

...

@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/rds Issues and PRs that pertain to the rds service. documentation Introduces or discusses updates to documentation. labels Jan 19, 2019
@bculberson bculberson changed the title GH-7212 allow for optional parameters on cluster with global rds Fixing global rds by allowing for optional parameters on cluster Jan 19, 2019
@bculberson bculberson closed this Jan 21, 2019
@bculberson bculberson reopened this Jan 22, 2019
@ghost ghost added size/S Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Jan 23, 2019
@ghost ghost added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Feb 11, 2019
@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Feb 12, 2019
@adamscharf
Copy link

adamscharf commented Feb 15, 2019

I'd really like to see this merged as I'm facing the issues outlined in #7212

Edit: Fixed typo

@bflad bflad added the bug Addresses a defect in current functionality. label Feb 22, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @bculberson 👋 Thank you so much for fixing this. I left a few notes below, but we'll definitely do the merge for the resource and documentation updates as they are good to go with the very minor adjustment to prevent a Terraform crash. 🚀

return fmt.Errorf(`provider.aws: aws_rds_cluster: %s: "master_username": required field is not set`, d.Get("database_name").(string))
if _, ok := d.GetOk("global_cluster_identifier"); !ok {
if _, ok := d.GetOk("master_password"); !ok {
return fmt.Errorf(`provider.aws: aws_db_instance: %s: "master_password": required field is not set`, d.Get("name").(string))
Copy link
Contributor

Choose a reason for hiding this comment

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

name is not an attribute in this resource's schema, so can cause a panic as found by the acceptance testing:

=== CONT  TestAccAWSRDSCluster_missingUserNameCausesError

------- Stderr: -------
panic: interface conversion: interface {} is nil, not string

goroutine 137 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsRDSClusterCreate(0xc000349260, 0x3c28320, 0xc0001adc00, 0xc000349260, 0x0)
	/opt/teamcity-agent/work/2e10e023da0c7520/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_rds_cluster.go:718 +0x6d9d

Will fix this on merge.

%s

resource "aws_rds_cluster" "test" {
depends_on = ["aws_db_subnet_group.dbsubnet"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using depends_on here, a direct reference can be used below instead:

  db_subnet_group_name = "${aws_db_subnet_group.dbsubnet.name}"

resource "aws_rds_global_cluster" "test" {
global_cluster_identifier = %q
}

resource "aws_rds_cluster" "test" {
depends_on = ["aws_db_subnet_group.dbsubnet"]
Copy link
Contributor

Choose a reason for hiding this comment

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

depends_on is extraneous here as there is already a direct reference below.

resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "terraform-acctest-rds-cluster-global-cross-region"
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting up cross-region acceptance testing is a pretty complicated undertaking (see also: TestAccAWSRDSCluster_EncryptedCrossRegionReplication). 😅 Since the implementation in 9b7a9b0 is only halfway there and has a few other little issues, opting to merge this pull request, but revert that commit until we can get a full, new test setup, preferably separate from the existing ones.

@bflad bflad added this to the v1.60.0 milestone Feb 22, 2019
@bflad bflad merged commit 9b7a9b0 into hashicorp:master Feb 22, 2019
bflad added a commit that referenced this pull request Feb 22, 2019
bflad added a commit that referenced this pull request Feb 22, 2019
…or master_username

Reference: #7213 (comment)

Previous output from acceptance testing:

```
=== CONT  TestAccAWSRDSCluster_missingUserNameCausesError

------- Stderr: -------
panic: interface conversion: interface {} is nil, not string

goroutine 137 [running]:
github.com/terraform-providers/terraform-provider-aws/aws.resourceAwsRDSClusterCreate(0xc000349260, 0x3c28320, 0xc0001adc00, 0xc000349260, 0x0)
	/opt/teamcity-agent/work/2e10e023da0c7520/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_rds_cluster.go:718 +0x6d9d
```

Output from acceptance testing:

```
--- PASS: TestAccAWSRDSCluster_missingUserNameCausesError (3.24s)
```
bflad added a commit that referenced this pull request Feb 22, 2019
@bflad
Copy link
Contributor

bflad commented Feb 22, 2019

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

@typez
Copy link

typez commented Oct 3, 2019

Unfortunately, it looks like this change hadn't actually fixed the problem. I had no luck at all trying to create a global RDS cluster via Terraform. There is a new related issue with all the details - #10188

@diprochatterjee
Copy link

Unfortunately this is still an issue. I have the same issue with creating a rds global cluster. The rds global cluster gets created but when I try to create an rds cluster as the primary cluster for the global cluster, it fails with error - * aws_rds_cluster.primary: error creating RDS cluster: InvalidParameterValue: The engine mode global you requested is currently unavailable. I am using Terraform version 0.11.11

@ghost
Copy link

ghost commented Nov 1, 2019

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 Nov 1, 2019
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. documentation Introduces or discusses updates to documentation. service/rds Issues and PRs that pertain to the rds service. size/M 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.

aws_rds_cluser global database support fails when second region is added
5 participants