Skip to content

Commit

Permalink
Adds domain and domain-iam-role-name parameters to resource aws_d…
Browse files Browse the repository at this point in the history
…b_instance.
  • Loading branch information
Mike Walker committed Jun 1, 2017
1 parent f27aa3c commit da38f61
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions builtin/providers/aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,18 @@ func resourceAwsDbInstance() *schema.Resource {
},

"resource_id": {
Type: schema.TypeString,
},

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

"domain-iam-role-name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

Expand Down Expand Up @@ -648,6 +659,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 @@ -764,6 +783,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 @@ -1015,6 +1039,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 da38f61

Please sign in to comment.