diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 05621fb5d3d3..2b5fbdc45587 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -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, }, @@ -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 { @@ -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 @@ -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)