From 1cd2fea1f911522dd167d6d296d2338744ec6999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Pre=C3=9F?= Date: Tue, 8 Dec 2015 14:55:17 +0100 Subject: [PATCH 1/3] Fix AWS RDS cross-region read replica always being placed in default VPC Fixes #4192 by honouring the `db_subnet_group_name` parameter when creating a cross-region read replica. --- builtin/providers/aws/resource_aws_db_instance.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index bd566b8a54..f0649d582f 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -271,6 +271,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), + DBSubnetGroupName: aws.String(d.Get("db_subnet_group_name").(string)), Tags: tags, } if attr, ok := d.GetOk("iops"); ok { @@ -288,6 +289,10 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error if attr, ok := d.GetOk("publicly_accessible"); ok { opts.PubliclyAccessible = aws.Bool(attr.(bool)) } + + if attr, ok := d.GetOk("db_subnet_group_name"); ok { + opts.DBSubnetGroupName = aws.String(attr.(string)) + } _, err := conn.CreateDBInstanceReadReplica(&opts) if err != nil { return fmt.Errorf("Error creating DB Instance: %s", err) From 0619898f6a6692b2cd5b0da96987da9cd67c681a Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 8 Dec 2015 10:52:17 -0600 Subject: [PATCH 2/3] provider/aws: Add arn to DB Instance output --- builtin/providers/aws/resource_aws_db_instance.go | 6 ++++++ .../source/docs/providers/aws/r/db_instance.html.markdown | 1 + 2 files changed, 7 insertions(+) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index f0649d582f..517fc738dd 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -31,6 +31,11 @@ func resourceAwsDbInstance() *schema.Resource { ForceNew: true, }, + "arn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + }, + "username": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -553,6 +558,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { } log.Printf("[DEBUG] Error building ARN for DB Instance, not setting Tags for DB %s", name) } else { + d.Set("arn", arn) resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{ ResourceName: aws.String(arn), }) diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index 55d13e250f..1c75f977a8 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -93,6 +93,7 @@ The following attributes are exported: * `id` - The RDS instance ID. * `address` - The address of the RDS instance. +* `arn` - The ARN of the RDS instance. * `allocated_storage` - The amount of allocated storage * `availability_zone` - The availability zone of the instance * `backup_retention_period` - The backup retention period From e52af33db7b2d03a34adb560eb4e37535a9a91d3 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 8 Dec 2015 10:55:57 -0600 Subject: [PATCH 3/3] remove extra DBSubnetGroupName --- builtin/providers/aws/resource_aws_db_instance.go | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 517fc738dd..3e9cb9d809 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -276,7 +276,6 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), - DBSubnetGroupName: aws.String(d.Get("db_subnet_group_name").(string)), Tags: tags, } if attr, ok := d.GetOk("iops"); ok {