-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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: Adds support for domain joining RDS instances #5378
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e7806b1
Adds domain and domain-iam-role-name parameters to resource aws_db_in…
2ad8d53
Adds domain and domain-iam-role-name parameters to resource aws_db_in…
mburtless 24d72f2
Merge branch 'master' into rds-add-domain
mburtless 9a2b871
Removes Computed attributes from domain and domain_iam_role_name, add…
mburtless 6d7c4f5
Updated name of config for domain acceptance test to match standard
mburtless 24ab317
Minor bug fixes and adds acceptance test step to ensure updating doma…
mburtless a0effd4
Merge branch 'rds-add-domain' of https://github.com/mburtless/terrafo…
mburtless c86a557
Merge branch 'master' into rds-add-domain
mburtless 82e6057
Removed commented test code
mburtless 6f8e687
Merge branch 'rds-add-domain' of https://github.com/mburtless/terrafo…
mburtless 5e2da4a
Adds support for domain and domain_iam_role_name to RestoreDBInstance…
mburtless f8ed378
Merge branch 'master' into rds-add-domain
mburtless File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,6 +407,16 @@ func resourceAwsDbInstance() *schema.Resource { | |
}, | ||
}, | ||
|
||
"domain": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
|
||
"domain_iam_role_name": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
|
||
"tags": tagsSchema(), | ||
}, | ||
} | ||
|
@@ -777,6 +787,14 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error | |
opts.DBSubnetGroupName = aws.String(attr.(string)) | ||
} | ||
|
||
if attr, ok := d.GetOk("domain"); ok { | ||
opts.Domain = aws.String(attr.(string)) | ||
} | ||
|
||
if attr, ok := d.GetOk("domain_iam_role_name"); ok { | ||
opts.DomainIAMRoleName = aws.String(attr.(string)) | ||
} | ||
|
||
if attr, ok := d.GetOk("enabled_cloudwatch_logs_exports"); ok && len(attr.([]interface{})) > 0 { | ||
opts.EnableCloudwatchLogsExports = expandStringList(attr.([]interface{})) | ||
} | ||
|
@@ -1003,6 +1021,14 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error | |
opts.EnableIAMDatabaseAuthentication = aws.Bool(attr.(bool)) | ||
} | ||
|
||
if attr, ok := d.GetOk("domain"); ok { | ||
opts.Domain = aws.String(attr.(string)) | ||
} | ||
|
||
if attr, ok := d.GetOk("domain_iam_role_name"); ok { | ||
opts.DomainIAMRoleName = aws.String(attr.(string)) | ||
} | ||
|
||
log.Printf("[DEBUG] DB Instance create configuration: %#v", opts) | ||
var err error | ||
err = resource.Retry(5*time.Minute, func() *resource.RetryError { | ||
|
@@ -1153,6 +1179,11 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { | |
return fmt.Errorf("error setting enabled_cloudwatch_logs_exports: %s", err) | ||
} | ||
|
||
if len(v.DomainMemberships) > 0 && v.DomainMemberships[0] != nil { | ||
d.Set("domain", v.DomainMemberships[0].Domain) | ||
d.Set("domain_iam_role_name", v.DomainMemberships[0].IAMRoleName) | ||
} | ||
|
||
// list tags for resource | ||
// set tags | ||
conn := meta.(*AWSClient).rdsconn | ||
|
@@ -1412,6 +1443,14 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error | |
requestUpdate = true | ||
} | ||
|
||
if (d.HasChange("domain") || d.HasChange("domain_iam_role_name")) && !d.IsNewResource() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We very recently fixed the resource so it does not call the Update function after the Create function, so the |
||
d.SetPartial("domain") | ||
d.SetPartial("domain_iam_role_name") | ||
req.Domain = aws.String(d.Get("domain").(string)) | ||
req.DomainIAMRoleName = aws.String(d.Get("domain_iam_role_name").(string)) | ||
requestUpdate = true | ||
} | ||
|
||
log.Printf("[DEBUG] Send DB Instance Modification request: %t", requestUpdate) | ||
if requestUpdate { | ||
log.Printf("[DEBUG] DB Instance Modification request: %s", req) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To detect drift when the domain membership is removed out of band of Terraform, we should ensure the Terraform state always starts with
""
, e.g.👍