Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/aws: aws_redshift_subnet_group allows description to be modified #9515

Merged
merged 1 commit into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion builtin/providers/aws/resource_aws_redshift_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func resourceAwsRedshiftSubnetGroupRead(d *schema.ResourceData, meta interface{}

func resourceAwsRedshiftSubnetGroupUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).redshiftconn
if d.HasChange("subnet_ids") {
if d.HasChange("subnet_ids") || d.HasChange("description") {
_, n := d.GetChange("subnet_ids")
if n == nil {
n = new(schema.Set)
Expand All @@ -117,6 +117,7 @@ func resourceAwsRedshiftSubnetGroupUpdate(d *schema.ResourceData, meta interface

_, err := conn.ModifyClusterSubnetGroup(&redshift.ModifyClusterSubnetGroupInput{
ClusterSubnetGroupName: aws.String(d.Id()),
Description: aws.String(d.Get("description").(string)),
SubnetIds: sIds,
})

Expand Down
60 changes: 60 additions & 0 deletions builtin/providers/aws/resource_aws_redshift_subnet_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@ func TestAccAWSRedshiftSubnetGroup_basic(t *testing.T) {
})
}

func TestAccAWSRedshiftSubnetGroup_updateDescription(t *testing.T) {
var v redshift.ClusterSubnetGroup

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRedshiftSubnetGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRedshiftSubnetGroupConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRedshiftSubnetGroupExists("aws_redshift_subnet_group.foo", &v),
resource.TestCheckResourceAttr(
"aws_redshift_subnet_group.foo", "description", "foo description"),
),
},

resource.TestStep{
Config: testAccRedshiftSubnetGroup_updateDescription,
Check: resource.ComposeTestCheckFunc(
testAccCheckRedshiftSubnetGroupExists("aws_redshift_subnet_group.foo", &v),
resource.TestCheckResourceAttr(
"aws_redshift_subnet_group.foo", "description", "foo description updated"),
),
},
},
})
}

func TestAccAWSRedshiftSubnetGroup_updateSubnetIds(t *testing.T) {
var v redshift.ClusterSubnetGroup

Expand Down Expand Up @@ -177,6 +206,37 @@ resource "aws_subnet" "bar" {

resource "aws_redshift_subnet_group" "foo" {
name = "foo"
description = "foo description"
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
}
`

const testAccRedshiftSubnetGroup_updateDescription = `
resource "aws_vpc" "foo" {
cidr_block = "10.1.0.0/16"
}

resource "aws_subnet" "foo" {
cidr_block = "10.1.1.0/24"
availability_zone = "us-west-2a"
vpc_id = "${aws_vpc.foo.id}"
tags {
Name = "tf-dbsubnet-test-1"
}
}

resource "aws_subnet" "bar" {
cidr_block = "10.1.2.0/24"
availability_zone = "us-west-2b"
vpc_id = "${aws_vpc.foo.id}"
tags {
Name = "tf-dbsubnet-test-2"
}
}

resource "aws_redshift_subnet_group" "foo" {
name = "foo"
description = "foo description updated"
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
}
`
Expand Down