Skip to content

Commit

Permalink
Merge pull request #23444 from hashicorp/b-dms-endpoint-ignored
Browse files Browse the repository at this point in the history
dms/endpoint: Fix bug where KMS key ignored
  • Loading branch information
YakDriver authored Mar 2, 2022
2 parents 7444e9f + aa837bb commit 3cc4c9b
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .changelog/23444.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_dms_endpoint: Fix bug where KMS key was ignored for DynamoDB, OpenSearch, Kafka, Kinesis, Oracle, PostgreSQL, and S3 engines.
```
36 changes: 18 additions & 18 deletions internal/service/dms/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,24 @@ func resourceEndpointCreate(d *schema.ResourceData, meta interface{}) error {
Tags: Tags(tags.IgnoreAWS()),
}

if v, ok := d.GetOk("certificate_arn"); ok {
request.CertificateArn = aws.String(v.(string))
}

// Send ExtraConnectionAttributes in the API request for all resource types
// per https://github.com/hashicorp/terraform-provider-aws/issues/8009
if v, ok := d.GetOk("extra_connection_attributes"); ok {
request.ExtraConnectionAttributes = aws.String(v.(string))
}

if v, ok := d.GetOk("kms_key_arn"); ok {
request.KmsKeyId = aws.String(v.(string))
}

if v, ok := d.GetOk("ssl_mode"); ok {
request.SslMode = aws.String(v.(string))
}

switch d.Get("engine_name").(string) {
case engineNameDynamoDB:
request.DynamoDbSettings = &dms.DynamoDbSettings{
Expand Down Expand Up @@ -697,24 +715,6 @@ func resourceEndpointCreate(d *schema.ResourceData, meta interface{}) error {
if v, ok := d.GetOk("database_name"); ok {
request.DatabaseName = aws.String(v.(string))
}

if v, ok := d.GetOk("kms_key_arn"); ok {
request.KmsKeyId = aws.String(v.(string))
}
}

if v, ok := d.GetOk("certificate_arn"); ok {
request.CertificateArn = aws.String(v.(string))
}

// Send ExtraConnectionAttributes in the API request for all resource types
// per https://github.com/hashicorp/terraform-provider-aws/issues/8009
if v, ok := d.GetOk("extra_connection_attributes"); ok {
request.ExtraConnectionAttributes = aws.String(v.(string))
}

if v, ok := d.GetOk("ssl_mode"); ok {
request.SslMode = aws.String(v.(string))
}

log.Println("[DEBUG] DMS create endpoint:", request)
Expand Down
Loading

0 comments on commit 3cc4c9b

Please sign in to comment.