From 57300d32c6e1a41a4370254f525276fb3ae62c35 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 20 Feb 2015 08:55:54 -0600 Subject: [PATCH 1/6] merge master --- builtin/providers/aws/config.go | 10 ++- .../aws/resource_aws_autoscaling_group.go | 75 +++++++++---------- .../resource_aws_autoscaling_group_test.go | 4 +- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index 460018929..a27bb841a 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -7,13 +7,13 @@ import ( "unicode" "github.com/hashicorp/terraform/helper/multierror" - "github.com/mitchellh/goamz/autoscaling" "github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/elb" "github.com/mitchellh/goamz/rds" awsGo "github.com/awslabs/aws-sdk-go/aws" + "github.com/awslabs/aws-sdk-go/gen/autoscaling" "github.com/awslabs/aws-sdk-go/gen/route53" "github.com/awslabs/aws-sdk-go/gen/s3" ) @@ -57,23 +57,25 @@ func (c *Config) Client() (interface{}, error) { // store AWS region in client struct, for region specific operations such as // bucket storage in S3 client.region = c.Region + creds := awsGo.Creds(c.AccessKey, c.SecretKey, "") log.Println("[INFO] Initializing EC2 connection") client.ec2conn = ec2.New(auth, region) log.Println("[INFO] Initializing ELB connection") client.elbconn = elb.New(auth, region) - log.Println("[INFO] Initializing AutoScaling connection") - client.autoscalingconn = autoscaling.New(auth, region) log.Println("[INFO] Initializing S3 connection") + client.s3conn = s3.New(creds, c.Region, nil) log.Println("[INFO] Initializing RDS connection") client.rdsconn = rds.New(auth, region) + log.Println("[INFO] Initializing Route53 connection") // aws-sdk-go uses v4 for signing requests, which requires all global // endpoints to use 'us-east-1'. // See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html client.r53conn = route53.New(creds, "us-east-1", nil) - client.s3conn = s3.New(creds, c.Region, nil) + log.Println("[INFO] Initializing AutoScaling connection") + client.autoscalingconn = autoscaling.New(creds, c.Region, nil) } if len(errs) > 0 { diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index e5ef587a0..8ab020de4 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -9,7 +9,9 @@ import ( "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" - "github.com/mitchellh/goamz/autoscaling" + + "github.com/awslabs/aws-sdk-go/aws" + "github.com/awslabs/aws-sdk-go/gen/autoscaling" ) func resourceAwsAutoscalingGroup() *schema.Resource { @@ -123,30 +125,25 @@ func resourceAwsAutoscalingGroup() *schema.Resource { func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) error { autoscalingconn := meta.(*AWSClient).autoscalingconn - var autoScalingGroupOpts autoscaling.CreateAutoScalingGroup - autoScalingGroupOpts.Name = d.Get("name").(string) - autoScalingGroupOpts.HealthCheckType = d.Get("health_check_type").(string) - autoScalingGroupOpts.LaunchConfigurationName = d.Get("launch_configuration").(string) - autoScalingGroupOpts.MinSize = d.Get("min_size").(int) - autoScalingGroupOpts.MaxSize = d.Get("max_size").(int) - autoScalingGroupOpts.SetMinSize = true - autoScalingGroupOpts.SetMaxSize = true - autoScalingGroupOpts.AvailZone = expandStringList( + var autoScalingGroupOpts autoscaling.CreateAutoScalingGroupType + autoScalingGroupOpts.AutoScalingGroupName = aws.String(d.Get("name").(string)) + autoScalingGroupOpts.HealthCheckType = aws.String(d.Get("health_check_type").(string)) + autoScalingGroupOpts.LaunchConfigurationName = aws.String(d.Get("launch_configuration").(string)) + autoScalingGroupOpts.MinSize = aws.Integer(d.Get("min_size").(int)) + autoScalingGroupOpts.MaxSize = aws.Integer(d.Get("max_size").(int)) + autoScalingGroupOpts.AvailabilityZones = expandStringList( d.Get("availability_zones").(*schema.Set).List()) if v, ok := d.GetOk("default_cooldown"); ok { - autoScalingGroupOpts.DefaultCooldown = v.(int) - autoScalingGroupOpts.SetDefaultCooldown = true + autoScalingGroupOpts.DefaultCooldown = aws.Integer(v.(int)) } if v, ok := d.GetOk("desired_capacity"); ok { - autoScalingGroupOpts.DesiredCapacity = v.(int) - autoScalingGroupOpts.SetDesiredCapacity = true + autoScalingGroupOpts.DesiredCapacity = aws.Integer(v.(int)) } if v, ok := d.GetOk("health_check_grace_period"); ok { - autoScalingGroupOpts.HealthCheckGracePeriod = v.(int) - autoScalingGroupOpts.SetHealthCheckGracePeriod = true + autoScalingGroupOpts.HealthCheckGracePeriod = aws.Integer(v.(int)) } if v, ok := d.GetOk("load_balancers"); ok && v.(*schema.Set).Len() > 0 { @@ -155,8 +152,10 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) } if v, ok := d.GetOk("vpc_zone_identifier"); ok && v.(*schema.Set).Len() > 0 { - autoScalingGroupOpts.VPCZoneIdentifier = expandStringList( - v.(*schema.Set).List()) + exp := expandStringList(v.(*schema.Set).List()) + log.Printf("\n\nexp:\n\t%#v\n\n", exp) + el := strings.Join(exp, ",") + autoScalingGroupOpts.VPCZoneIdentifier = aws.String(el) } if v, ok := d.GetOk("termination_policies"); ok && v.(*schema.Set).Len() > 0 { @@ -165,7 +164,7 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] AutoScaling Group create configuration: %#v", autoScalingGroupOpts) - _, err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts) + err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts) if err != nil { return fmt.Errorf("Error creating Autoscaling Group: %s", err) } @@ -194,8 +193,8 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e d.Set("load_balancers", g.LoadBalancerNames) d.Set("min_size", g.MinSize) d.Set("max_size", g.MaxSize) - d.Set("name", g.Name) - d.Set("vpc_zone_identifier", strings.Split(g.VPCZoneIdentifier, ",")) + d.Set("name", g.AutoScalingGroupName) + d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ",")) d.Set("termination_policies", g.TerminationPolicies) return nil @@ -204,31 +203,28 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{}) error { autoscalingconn := meta.(*AWSClient).autoscalingconn - opts := autoscaling.UpdateAutoScalingGroup{ - Name: d.Id(), + opts := autoscaling.UpdateAutoScalingGroupType{ + AutoScalingGroupName: aws.String(d.Id()), } if d.HasChange("desired_capacity") { - opts.DesiredCapacity = d.Get("desired_capacity").(int) - opts.SetDesiredCapacity = true + opts.DesiredCapacity = aws.Integer(d.Get("desired_capacity").(int)) } if d.HasChange("launch_configuration") { - opts.LaunchConfigurationName = d.Get("launch_configuration").(string) + opts.LaunchConfigurationName = aws.String(d.Get("launch_configuration").(string)) } if d.HasChange("min_size") { - opts.MinSize = d.Get("min_size").(int) - opts.SetMinSize = true + opts.MinSize = aws.Integer(d.Get("min_size").(int)) } if d.HasChange("max_size") { - opts.MaxSize = d.Get("max_size").(int) - opts.SetMaxSize = true + opts.MaxSize = aws.Integer(d.Get("max_size").(int)) } log.Printf("[DEBUG] AutoScaling Group update configuration: %#v", opts) - _, err := autoscalingconn.UpdateAutoScalingGroup(&opts) + err := autoscalingconn.UpdateAutoScalingGroup(&opts) if err != nil { d.Partial(true) return fmt.Errorf("Error updating Autoscaling group: %s", err) @@ -250,14 +246,14 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{}) if g == nil { return nil } - if len(g.Instances) > 0 || g.DesiredCapacity > 0 { + if len(g.Instances) > 0 || *g.DesiredCapacity > 0 { if err := resourceAwsAutoscalingGroupDrain(d, meta); err != nil { return err } } log.Printf("[DEBUG] AutoScaling Group destroy: %v", d.Id()) - deleteopts := autoscaling.DeleteAutoScalingGroup{Name: d.Id()} + deleteopts := autoscaling.DeleteAutoScalingGroupType{AutoScalingGroupName: aws.String(d.Id())} // You can force an autoscaling group to delete // even if it's in the process of scaling a resource. @@ -265,15 +261,14 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{}) // and then delete the group. This bypasses that and leaves // resources potentially dangling. if d.Get("force_delete").(bool) { - deleteopts.ForceDelete = true + deleteopts.ForceDelete = aws.Boolean(true) } - if _, err := autoscalingconn.DeleteAutoScalingGroup(&deleteopts); err != nil { - autoscalingerr, ok := err.(*autoscaling.Error) + if err := autoscalingconn.DeleteAutoScalingGroup(&deleteopts); err != nil { + autoscalingerr, ok := err.(aws.APIError) if ok && autoscalingerr.Code == "InvalidGroup.NotFound" { return nil } - return err } @@ -285,14 +280,14 @@ func getAwsAutoscalingGroup( meta interface{}) (*autoscaling.AutoScalingGroup, error) { autoscalingconn := meta.(*AWSClient).autoscalingconn - describeOpts := autoscaling.DescribeAutoScalingGroups{ - Names: []string{d.Id()}, + describeOpts := autoscaling.AutoScalingGroupNamesType{ + AutoScalingGroupNames: []string{d.Id()}, } log.Printf("[DEBUG] AutoScaling Group describe configuration: %#v", describeOpts) describeGroups, err := autoscalingconn.DescribeAutoScalingGroups(&describeOpts) if err != nil { - autoscalingerr, ok := err.(*autoscaling.Error) + autoscalingerr, ok := err.(aws.APIError) if ok && autoscalingerr.Code == "InvalidGroup.NotFound" { d.SetId("") return nil, nil diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index 531d51843..64f608f12 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -6,7 +6,9 @@ import ( "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - "github.com/mitchellh/goamz/autoscaling" + + _ "github.com/awslabs/aws-sdk-go/aws" + "github.com/awslabs/aws-sdk-go/gen/autoscaling" ) func TestAccAWSAutoScalingGroup_basic(t *testing.T) { From 08949866c5bbffa92a2a8192d913465921dd4bc8 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 20 Feb 2015 09:08:41 -0600 Subject: [PATCH 2/6] Merge config --- builtin/providers/aws/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index a27bb841a..5482cdbcd 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -69,10 +69,10 @@ func (c *Config) Client() (interface{}, error) { log.Println("[INFO] Initializing RDS connection") client.rdsconn = rds.New(auth, region) - log.Println("[INFO] Initializing Route53 connection") // aws-sdk-go uses v4 for signing requests, which requires all global // endpoints to use 'us-east-1'. // See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html + log.Println("[INFO] Initializing Route53 connection") client.r53conn = route53.New(creds, "us-east-1", nil) log.Println("[INFO] Initializing AutoScaling connection") client.autoscalingconn = autoscaling.New(creds, c.Region, nil) From b38a3767ebec96fa6c3f79f156d549e2f66b75b5 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 20 Feb 2015 11:28:20 -0600 Subject: [PATCH 3/6] provider/aws: Convert AWS AutoScalingGroup to awslabs/aws-sdk-go --- builtin/providers/aws/config.go | 24 ++++++++++------- .../aws/resource_aws_autoscaling_group.go | 27 +++++++++---------- .../resource_aws_autoscaling_group_test.go | 4 +-- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index 5482cdbcd..47e1c00fb 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -7,13 +7,14 @@ import ( "unicode" "github.com/hashicorp/terraform/helper/multierror" + "github.com/mitchellh/goamz/autoscaling" "github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/elb" "github.com/mitchellh/goamz/rds" awsGo "github.com/awslabs/aws-sdk-go/aws" - "github.com/awslabs/aws-sdk-go/gen/autoscaling" + awsAutoScaling "github.com/awslabs/aws-sdk-go/gen/autoscaling" "github.com/awslabs/aws-sdk-go/gen/route53" "github.com/awslabs/aws-sdk-go/gen/s3" ) @@ -25,13 +26,14 @@ type Config struct { } type AWSClient struct { - ec2conn *ec2.EC2 - elbconn *elb.ELB - autoscalingconn *autoscaling.AutoScaling - s3conn *s3.S3 - rdsconn *rds.Rds - r53conn *route53.Route53 - region string + ec2conn *ec2.EC2 + elbconn *elb.ELB + autoscalingconn *autoscaling.AutoScaling + s3conn *s3.S3 + rdsconn *rds.Rds + r53conn *route53.Route53 + region string + awsAutoScalingconn *awsAutoScaling.AutoScaling } // Client configures and returns a fully initailized AWSClient @@ -64,6 +66,8 @@ func (c *Config) Client() (interface{}, error) { client.ec2conn = ec2.New(auth, region) log.Println("[INFO] Initializing ELB connection") client.elbconn = elb.New(auth, region) + log.Println("[INFO] Initializing AutoScaling connection") + client.autoscalingconn = autoscaling.New(auth, region) log.Println("[INFO] Initializing S3 connection") client.s3conn = s3.New(creds, c.Region, nil) log.Println("[INFO] Initializing RDS connection") @@ -74,8 +78,8 @@ func (c *Config) Client() (interface{}, error) { // See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html log.Println("[INFO] Initializing Route53 connection") client.r53conn = route53.New(creds, "us-east-1", nil) - log.Println("[INFO] Initializing AutoScaling connection") - client.autoscalingconn = autoscaling.New(creds, c.Region, nil) + log.Println("[INFO] Initializing AWS Go AutoScaling connection") + client.awsAutoScalingconn = awsAutoScaling.New(creds, c.Region, nil) } if len(errs) > 0 { diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 8ab020de4..95579eda2 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -123,7 +123,7 @@ func resourceAwsAutoscalingGroup() *schema.Resource { } func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) error { - autoscalingconn := meta.(*AWSClient).autoscalingconn + autoscalingconn := meta.(*AWSClient).awsAutoScalingconn var autoScalingGroupOpts autoscaling.CreateAutoScalingGroupType autoScalingGroupOpts.AutoScalingGroupName = aws.String(d.Get("name").(string)) @@ -201,7 +201,7 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e } func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{}) error { - autoscalingconn := meta.(*AWSClient).autoscalingconn + autoscalingconn := meta.(*AWSClient).awsAutoScalingconn opts := autoscaling.UpdateAutoScalingGroupType{ AutoScalingGroupName: aws.String(d.Id()), @@ -234,7 +234,7 @@ func resourceAwsAutoscalingGroupUpdate(d *schema.ResourceData, meta interface{}) } func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{}) error { - autoscalingconn := meta.(*AWSClient).autoscalingconn + autoscalingconn := meta.(*AWSClient).awsAutoScalingconn // Read the autoscaling group first. If it doesn't exist, we're done. // We need the group in order to check if there are instances attached. @@ -278,7 +278,7 @@ func resourceAwsAutoscalingGroupDelete(d *schema.ResourceData, meta interface{}) func getAwsAutoscalingGroup( d *schema.ResourceData, meta interface{}) (*autoscaling.AutoScalingGroup, error) { - autoscalingconn := meta.(*AWSClient).autoscalingconn + autoscalingconn := meta.(*AWSClient).awsAutoScalingconn describeOpts := autoscaling.AutoScalingGroupNamesType{ AutoScalingGroupNames: []string{d.Id()}, @@ -298,7 +298,7 @@ func getAwsAutoscalingGroup( // Search for the autoscaling group for idx, asc := range describeGroups.AutoScalingGroups { - if asc.Name == d.Id() { + if *asc.AutoScalingGroupName == d.Id() { return &describeGroups.AutoScalingGroups[idx], nil } } @@ -309,20 +309,17 @@ func getAwsAutoscalingGroup( } func resourceAwsAutoscalingGroupDrain(d *schema.ResourceData, meta interface{}) error { - autoscalingconn := meta.(*AWSClient).autoscalingconn + autoscalingconn := meta.(*AWSClient).awsAutoScalingconn // First, set the capacity to zero so the group will drain log.Printf("[DEBUG] Reducing autoscaling group capacity to zero") - opts := autoscaling.UpdateAutoScalingGroup{ - Name: d.Id(), - DesiredCapacity: 0, - MinSize: 0, - MaxSize: 0, - SetDesiredCapacity: true, - SetMinSize: true, - SetMaxSize: true, + opts := autoscaling.UpdateAutoScalingGroupType{ + AutoScalingGroupName: aws.String(d.Id()), + DesiredCapacity: aws.Integer(0), + MinSize: aws.Integer(0), + MaxSize: aws.Integer(0), } - if _, err := autoscalingconn.UpdateAutoScalingGroup(&opts); err != nil { + if err := autoscalingconn.UpdateAutoScalingGroup(&opts); err != nil { return fmt.Errorf("Error setting capacity to zero to drain: %s", err) } diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index 64f608f12..531d51843 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -6,9 +6,7 @@ import ( "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" - - _ "github.com/awslabs/aws-sdk-go/aws" - "github.com/awslabs/aws-sdk-go/gen/autoscaling" + "github.com/mitchellh/goamz/autoscaling" ) func TestAccAWSAutoScalingGroup_basic(t *testing.T) { From d79ac17757d9e564696904db646fe62e78707917 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 20 Feb 2015 11:40:47 -0600 Subject: [PATCH 4/6] randomize ASG name in test, to get around slow AWS delete time --- .../providers/aws/resource_aws_autoscaling_group_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index 531d51843..ab8c88342 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -2,7 +2,9 @@ package aws import ( "fmt" + "math/rand" "testing" + "time" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -241,7 +243,7 @@ resource "aws_autoscaling_group" "bar" { } ` -const testAccAWSAutoScalingGroupConfigWithLoadBalancer = ` +var testAccAWSAutoScalingGroupConfigWithLoadBalancer = fmt.Sprintf(` resource "aws_elb" "bar" { name = "foobar-terraform-test" availability_zones = ["us-west-2a"] @@ -262,7 +264,7 @@ resource "aws_launch_configuration" "foobar" { resource "aws_autoscaling_group" "bar" { availability_zones = ["us-west-2a"] - name = "foobar3-terraform-test" + name = "foobar3-terraform-test-%d" max_size = 5 min_size = 2 health_check_grace_period = 300 @@ -273,4 +275,4 @@ resource "aws_autoscaling_group" "bar" { launch_configuration = "${aws_launch_configuration.foobar.name}" load_balancers = ["${aws_elb.bar.name}"] } -` +`, rand.New(rand.NewSource(time.Now().UnixNano())).Intn(64)) From 4326b6b8b51be761cbc976d578678a48b45e777f Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 20 Feb 2015 14:27:48 -0600 Subject: [PATCH 5/6] cleanups after feedback --- .../aws/resource_aws_autoscaling_group.go | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 95579eda2..2a285cf18 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -153,9 +153,7 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) if v, ok := d.GetOk("vpc_zone_identifier"); ok && v.(*schema.Set).Len() > 0 { exp := expandStringList(v.(*schema.Set).List()) - log.Printf("\n\nexp:\n\t%#v\n\n", exp) - el := strings.Join(exp, ",") - autoScalingGroupOpts.VPCZoneIdentifier = aws.String(el) + autoScalingGroupOpts.VPCZoneIdentifier = aws.String(strings.Join(exp, ",")) } if v, ok := d.GetOk("termination_policies"); ok && v.(*schema.Set).Len() > 0 { @@ -185,15 +183,15 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e } d.Set("availability_zones", g.AvailabilityZones) - d.Set("default_cooldown", g.DefaultCooldown) - d.Set("desired_capacity", g.DesiredCapacity) - d.Set("health_check_grace_period", g.HealthCheckGracePeriod) - d.Set("health_check_type", g.HealthCheckType) - d.Set("launch_configuration", g.LaunchConfigurationName) + d.Set("default_cooldown", *g.DefaultCooldown) + d.Set("desired_capacity", *g.DesiredCapacity) + d.Set("health_check_grace_period", *g.HealthCheckGracePeriod) + d.Set("health_check_type", *g.HealthCheckType) + d.Set("launch_configuration", *g.LaunchConfigurationName) d.Set("load_balancers", g.LoadBalancerNames) - d.Set("min_size", g.MinSize) - d.Set("max_size", g.MaxSize) - d.Set("name", g.AutoScalingGroupName) + d.Set("min_size", *g.MinSize) + d.Set("max_size", *g.MaxSize) + d.Set("name", *g.AutoScalingGroupName) d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ",")) d.Set("termination_policies", g.TerminationPolicies) From 5b35b8552780b90a43fdbfc2a97954bdb1395187 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Fri, 20 Feb 2015 15:49:51 -0600 Subject: [PATCH 6/6] remove the rand, it's not helping like I thought --- .../providers/aws/resource_aws_autoscaling_group_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index ab8c88342..531d51843 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -2,9 +2,7 @@ package aws import ( "fmt" - "math/rand" "testing" - "time" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -243,7 +241,7 @@ resource "aws_autoscaling_group" "bar" { } ` -var testAccAWSAutoScalingGroupConfigWithLoadBalancer = fmt.Sprintf(` +const testAccAWSAutoScalingGroupConfigWithLoadBalancer = ` resource "aws_elb" "bar" { name = "foobar-terraform-test" availability_zones = ["us-west-2a"] @@ -264,7 +262,7 @@ resource "aws_launch_configuration" "foobar" { resource "aws_autoscaling_group" "bar" { availability_zones = ["us-west-2a"] - name = "foobar3-terraform-test-%d" + name = "foobar3-terraform-test" max_size = 5 min_size = 2 health_check_grace_period = 300 @@ -275,4 +273,4 @@ resource "aws_autoscaling_group" "bar" { launch_configuration = "${aws_launch_configuration.foobar.name}" load_balancers = ["${aws_elb.bar.name}"] } -`, rand.New(rand.NewSource(time.Now().UnixNano())).Intn(64)) +`