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.
This commit is contained in:
Philipp Preß 2015-12-08 14:55:17 +01:00
parent d69abbaeda
commit 1cd2fea1f9
1 changed files with 5 additions and 0 deletions

View File

@ -271,6 +271,7 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)), CopyTagsToSnapshot: aws.Bool(d.Get("copy_tags_to_snapshot").(bool)),
DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceClass: aws.String(d.Get("instance_class").(string)),
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)), DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
DBSubnetGroupName: aws.String(d.Get("db_subnet_group_name").(string)),
Tags: tags, Tags: tags,
} }
if attr, ok := d.GetOk("iops"); ok { 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 { if attr, ok := d.GetOk("publicly_accessible"); ok {
opts.PubliclyAccessible = aws.Bool(attr.(bool)) 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) _, err := conn.CreateDBInstanceReadReplica(&opts)
if err != nil { if err != nil {
return fmt.Errorf("Error creating DB Instance: %s", err) return fmt.Errorf("Error creating DB Instance: %s", err)