diff --git a/builtin/providers/aws/resource_aws_db_subnet_group_test.go b/builtin/providers/aws/resource_aws_db_subnet_group_test.go index 184df9c9a..ac9382c23 100644 --- a/builtin/providers/aws/resource_aws_db_subnet_group_test.go +++ b/builtin/providers/aws/resource_aws_db_subnet_group_test.go @@ -9,7 +9,7 @@ import ( "github.com/mitchellh/goamz/rds" ) -func TestAccAWSDbSubnetGroup(t *testing.T) { +func TestAccAWSDBSubnetGroup(t *testing.T) { var v rds.DBSubnetGroup testCheck := func(*terraform.State) error { @@ -19,12 +19,12 @@ func TestAccAWSDbSubnetGroup(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckDbSubnetGroupDestroy, + CheckDestroy: testAccCheckDBSubnetGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccDbSubnetGroupConfig, + Config: testAccDBSubnetGroupConfig, Check: resource.ComposeTestCheckFunc( - testAccCheckDbSubnetGroupExists( + testAccCheckDBSubnetGroupExists( "aws_db_subnet_group.foo", &v), testCheck, ), @@ -33,7 +33,7 @@ func TestAccAWSDbSubnetGroup(t *testing.T) { }) } -func testAccCheckDbSubnetGroupDestroy(s *terraform.State) error { +func testAccCheckDBSubnetGroupDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).rdsconn for _, rs := range s.RootModule().Resources { @@ -64,7 +64,7 @@ func testAccCheckDbSubnetGroupDestroy(s *terraform.State) error { return nil } -func testAccCheckDbSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.TestCheckFunc { +func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { @@ -90,18 +90,20 @@ func testAccCheckDbSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te } } -const testAccDbSubnetGroupConfig = ` +const testAccDBSubnetGroupConfig = ` 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}" } resource "aws_subnet" "bar" { cidr_block = "10.1.2.0/24" + availability_zone = "us-west-2b" vpc_id = "${aws_vpc.foo.id}" } diff --git a/builtin/providers/aws/resource_aws_instance_test.go b/builtin/providers/aws/resource_aws_instance_test.go index 7a735b7b2..9e326f81a 100644 --- a/builtin/providers/aws/resource_aws_instance_test.go +++ b/builtin/providers/aws/resource_aws_instance_test.go @@ -343,6 +343,8 @@ resource "aws_instance" "foo" { const testAccCheckInstanceConfigTags = ` resource "aws_instance" "foo" { + ami = "ami-4fccb37f" + instance_type = "m1.small" tags { foo = "bar" } @@ -351,6 +353,8 @@ resource "aws_instance" "foo" { const testAccCheckInstanceConfigTagsUpdate = ` resource "aws_instance" "foo" { + ami = "ami-4fccb37f" + instance_type = "m1.small" tags { bar = "baz" } diff --git a/builtin/providers/aws/resource_aws_route_table.go b/builtin/providers/aws/resource_aws_route_table.go index 75598b228..841e456dd 100644 --- a/builtin/providers/aws/resource_aws_route_table.go +++ b/builtin/providers/aws/resource_aws_route_table.go @@ -16,6 +16,7 @@ func resourceAwsRouteTable() *schema.Resource { return &schema.Resource{ Create: resourceAwsRouteTableCreate, Read: resourceAwsRouteTableRead, + Update: resourceAwsRouteTableUpdate, Delete: resourceAwsRouteTableDelete, Schema: map[string]*schema.Schema{ @@ -87,7 +88,7 @@ func resourceAwsRouteTableCreate(d *schema.ResourceData, meta interface{}) error d.Id(), err) } - return resourceAwsRouteTableRead(d, meta) + return resourceAwsRouteTableUpdate(d, meta) } func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error { @@ -104,7 +105,29 @@ func resourceAwsRouteTableRead(d *schema.ResourceData, meta interface{}) error { rt := rtRaw.(*ec2.RouteTable) d.Set("vpc_id", rt.VpcId) - // TODO: Add some code to also update the route set + // Create an empty schema.Set to hold all routes + route := &schema.Set{F: resourceAwsRouteTableHash} + + // Loop through the routes and add them to the set + for _, r := range rt.Routes { + if r.GatewayId == "local" { + continue + } + + m := make(map[string]interface{}) + m["cidr_block"] = r.DestinationCidrBlock + + if r.GatewayId != "" { + m["gateway_id"] = r.GatewayId + } + + if r.InstanceId != "" { + m["instance_id"] = r.InstanceId + } + + route.Add(m) + } + d.Set("route", route) return nil } diff --git a/builtin/providers/aws/resource_aws_s3_bucket_test.go b/builtin/providers/aws/resource_aws_s3_bucket_test.go index 9296df0d0..8571e0f9e 100644 --- a/builtin/providers/aws/resource_aws_s3_bucket_test.go +++ b/builtin/providers/aws/resource_aws_s3_bucket_test.go @@ -2,13 +2,17 @@ package aws import ( "fmt" + "math/rand" "testing" + "time" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func TestAccAWSS3Bucket(t *testing.T) { + rand.Seed(time.Now().UnixNano()) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -64,9 +68,11 @@ func testAccCheckAWSS3BucketExists(n string) resource.TestCheckFunc { } } -const testAccAWSS3BucketConfig = ` +// This needs a bit of randoness as the name can only be +// used once globally within AWS +var testAccAWSS3BucketConfig = fmt.Sprintf(` resource "aws_s3_bucket" "bar" { - bucket = "tf-test-bucket" + bucket = "tf-test-bucket-%d" acl = "public-read" } -` +`, rand.Int()) diff --git a/builtin/providers/aws/resource_aws_security_group.go b/builtin/providers/aws/resource_aws_security_group.go index 87fce98ff..d874bb996 100644 --- a/builtin/providers/aws/resource_aws_security_group.go +++ b/builtin/providers/aws/resource_aws_security_group.go @@ -275,7 +275,7 @@ func resourceAwsSecurityGroupUpdate(d *schema.ResourceData, meta interface{}) er d.SetPartial("tags") } - return nil + return resourceAwsSecurityGroupRead(d, meta) } func resourceAwsSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error { diff --git a/builtin/providers/aws/structure.go b/builtin/providers/aws/structure.go index 45ccbf093..2e634931b 100644 --- a/builtin/providers/aws/structure.go +++ b/builtin/providers/aws/structure.go @@ -192,9 +192,9 @@ func flattenParameters(list []rds.Parameter) []map[string]interface{} { result := make([]map[string]interface{}, 0, len(list)) for _, i := range list { result = append(result, map[string]interface{}{ - "name": strings.ToLower(i.ParameterName), - "value": strings.ToLower(i.ParameterValue), - }) + "name": strings.ToLower(i.ParameterName), + "value": strings.ToLower(i.ParameterValue), + }) } return result }