Skip to content

Commit

Permalink
Adds domain and domain-iam-role-name parameters to resource aws_db_in…
Browse files Browse the repository at this point in the history
…stance.
  • Loading branch information
Mike Walker committed Aug 8, 2017
1 parent 37cf4e6 commit e7806b1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ func resourceAwsDbInstance() *schema.Resource {
Computed: true,
},

"domain": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"domain_iam_role_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -660,6 +672,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 {
Expand Down Expand Up @@ -776,6 +796,11 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("monitoring_role_arn", v.MonitoringRoleArn)
}

if v.DomainMemberships != 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
Expand Down Expand Up @@ -1028,6 +1053,18 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
requestUpdate = true
}

if d.HasChange("domain") && !d.IsNewResource() {
d.SetPartial("domain")
req.Domain = aws.String(d.Get("domain").(string))
requestUpdate = true
}

if d.HasChange("domain_iam_role_name") && !d.IsNewResource() {
d.SetPartial("domain_iam_role_name")
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)
Expand Down

0 comments on commit e7806b1

Please sign in to comment.