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_db_instance: Allow ARN for the replicate_source_db when in the same region #2386

Closed
wants to merge 25 commits into from

Conversation

pccowboy
Copy link

@pccowboy pccowboy commented Nov 21, 2017

I believe this addresses a possible bug we ran into that was triggered by https://github.com/terraform-providers/terraform-provider-aws/pull/865/files and mentioned at https://groups.google.com/forum/#!topic/terraform-tool/zX-bWBZgViI

If you pass both an ARN and a kms_key_id to create a replica in the same region as the master, you get an error of the form "* aws_db_instance.read_replica: Error creating DB Instance: InvalidParameterCombination: Your request does not require the preSignedUrl parameter. Please remove the preSignedUrl parameter and try your request again."

I think this is because of AWS code - in aws/aws-sdk-go/service/rds/customizations.go, a preSignedUrl will get added to the CreateDBInstanceReadReplicaInput if the SourceRegion is set for the replica. If SourceRegion is nil, the presignedURL is skipped.

     58         if originParams.SourceRegion == nil || originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil {
     59                 return
     60         }

We are still verifying that this is working for our installation, hence the WIP tag. We are able to create the same-region replica reliably (after push c84c16d), but we are getting a destroy-add on the next plan for the replica. We are tracking that down currently.

I've modified the test for creating a replica, and added two more, one for the replica created with a source ARN in the same region, and one for creating a replica from a source ARN in a different region. I have not yet run the tests, however.

@pccowboy
Copy link
Author

@Ninir Can you take a look at this latest, and tell me if it looks like a valid fix for #2399 ? If it looks like a fix y'all might take, we'll test it out, since testing it costs some money.

Otherwise, any pointers on producing a fix? This is not blocking us, but it did make us create a module specific to same-region replicas, which seems less than ideal.

@pccowboy
Copy link
Author

@Ninir ping? We are using this fix currently, and it seems to be working. Any feedback y'all have on the current PR would be appreciated.

@pccowboy pccowboy changed the title [WIP] Allow ARN for the replicate_source_db when in the same region Allow ARN for the replicate_source_db when in the same region Dec 15, 2017
@pccowboy
Copy link
Author

@radeksimko @Ninir Hello, can we get your feedback on this PR, please?

@@ -407,11 +437,11 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.DBSubnetGroupName = aws.String(attr.(string))
}

// TODO: Only allow this param if the master is not encrypted or
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still an outstanding concern?

Copy link
Author

Choose a reason for hiding this comment

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

@jen20 I wrote that based on the ambiguity in the AWS documentation I describe above. When creating a replica, they seem to have two situations where they allow an encryption key to be specified for a replica. When creating an encrypted replica in the same region as the master, you cannot specify the key.

I had thought that maybe we should show an error if a key was specified for a same-region replica.

However, maybe it is best to let the AWS API throw an error if this param is used when it is not allowed.

Unless you have advice on which way to go, I can take those lines out. The PR is working as-is for us.

Copy link
Contributor

@jen20 jen20 left a comment

Choose a reason for hiding this comment

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

I have a couple of questions and haven't tried running the tests yet, but overall this looks fairly solid. Thanks for the PR!

@@ -399,6 +401,34 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.AvailabilityZone = aws.String(attr.(string))
}

//
// If we are called with a Source DB ARN, and the ARN is a different region
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 for the block comment explaining the rationale here.

@radeksimko radeksimko added the service/rds Issues and PRs that pertain to the rds service. label Jan 16, 2018
@radeksimko radeksimko changed the title Allow ARN for the replicate_source_db when in the same region resource/aws_db_instance: Allow ARN for the replicate_source_db when in the same region Jan 16, 2018
@pccowboy
Copy link
Author

@radeksimko Is there anything about this PR that is blocking it from being merged in? I am happy to make whatever adjustments are needed.

@pccowboy
Copy link
Author

pccowboy commented Mar 8, 2018

@radeksimko bump -anything I can do to move this through?

@pccowboy
Copy link
Author

pccowboy commented Mar 8, 2018

@radeksimko @jen20 Actually, I have a cleaner branch, where I removed all the duplicate commits. I think I am going to close this PR, and open a new one from that cleaner branch.

@ghost
Copy link

ghost commented Apr 7, 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 7, 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. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants