-
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_db_instance: Allow ARN for the replicate_source_db when in the same region #2386
Conversation
Add test for same-region replicas, verify that source_region is not set.
aws client bits instead.
@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. |
@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. |
@radeksimko @Ninir Hello, can we get your feedback on this PR, please? |
Add test for same-region replicas, verify that source_region is not set.
aws client bits instead.
@@ -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 |
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.
Is this still an outstanding concern?
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.
@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.
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.
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 |
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.
👍 for the block comment explaining the rationale here.
@radeksimko Is there anything about this PR that is blocking it from being merged in? I am happy to make whatever adjustments are needed. |
@radeksimko bump -anything I can do to move this through? |
@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. |
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! |
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.
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.