From 7d4064ca03a2259459ed0e8c0f891a0f9bd4f539 Mon Sep 17 00:00:00 2001 From: Madhu Date: Thu, 23 Oct 2014 14:58:54 -0700 Subject: [PATCH 1/4] Termination Policy Support --- .../aws/resource_aws_autoscaling_group.go | 17 +++++++++++++++++ .../aws/resource_aws_autoscaling_group_test.go | 5 ++++- .../providers/aws/r/autoscale.html.markdown | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 54c744989..5ed487d72 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -12,6 +12,7 @@ import ( ) func resourceAwsAutoscalingGroup() *schema.Resource { + fmt.Println("HELLO WORLD") return &schema.Resource{ Create: resourceAwsAutoscalingGroupCreate, Read: resourceAwsAutoscalingGroupRead, @@ -105,6 +106,17 @@ func resourceAwsAutoscalingGroup() *schema.Resource { return hashcode.String(v.(string)) }, }, + + "termination_policies": &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Computed: true, + ForceNew: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Set: func(v interface{}) int { + return hashcode.String(v.(string)) + }, + }, }, } } @@ -148,6 +160,11 @@ func resourceAwsAutoscalingGroupCreate(d *schema.ResourceData, meta interface{}) autoScalingGroupOpts.VPCZoneIdentifier = expandStringList( v.(*schema.Set).List()) } + + if v, ok := d.GetOk("termination_policies"); ok { + autoScalingGroupOpts.TerminationPolicies = expandStringList( + v.(*schema.Set).List()) + } log.Printf("[DEBUG] AutoScaling Group create configuration: %#v", autoScalingGroupOpts) _, err := autoscalingconn.CreateAutoScalingGroup(&autoScalingGroupOpts) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index 79ce2f6b7..74efd82b1 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -38,6 +38,8 @@ func TestAccAWSAutoScalingGroup_basic(t *testing.T) { "aws_autoscaling_group.bar", "desired_capacity", "4"), resource.TestCheckResourceAttr( "aws_autoscaling_group.bar", "force_delete", "true"), + resource.TestCheckResourceAttr( + "aws_autoscaling_group.bar", "termination_policies.0", "OldestInstance"), ), }, @@ -202,7 +204,8 @@ resource "aws_autoscaling_group" "bar" { health_check_type = "ELB" desired_capacity = 4 force_delete = true - + termination_policies = ["OldestInstance"] + launch_configuration = "${aws_launch_configuration.foobar.name}" } ` diff --git a/website/source/docs/providers/aws/r/autoscale.html.markdown b/website/source/docs/providers/aws/r/autoscale.html.markdown index a10dec4ce..bb592a819 100644 --- a/website/source/docs/providers/aws/r/autoscale.html.markdown +++ b/website/source/docs/providers/aws/r/autoscale.html.markdown @@ -43,6 +43,7 @@ The following arguments are supported: * `load_balancers` (Optional) A list of load balancer names to add to the autoscaling group names. * `vpc_zone_identifier` (Optional) A list of subnet IDs to launch resources in. +* `termination_policies` (Optional) A list of policies to decide how the instances in the auto scale group should be terminated. ## Attributes Reference From 5085e75f4a2d64aa7d3f298fb2ad673d31fa6d30 Mon Sep 17 00:00:00 2001 From: Madhu Date: Thu, 23 Oct 2014 15:50:17 -0700 Subject: [PATCH 2/4] Remove debug logs --- builtin/providers/aws/resource_aws_autoscaling_group.go | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index 5ed487d72..e89f248be 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -12,7 +12,6 @@ import ( ) func resourceAwsAutoscalingGroup() *schema.Resource { - fmt.Println("HELLO WORLD") return &schema.Resource{ Create: resourceAwsAutoscalingGroupCreate, Read: resourceAwsAutoscalingGroupRead, From a987ce3db062c6f8515da71777bb9381e752e267 Mon Sep 17 00:00:00 2001 From: Madhu Date: Thu, 20 Nov 2014 14:16:24 -0800 Subject: [PATCH 3/4] so my fix works --- builtin/bins/provider-aws/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/bins/provider-aws/main.go b/builtin/bins/provider-aws/main.go index 5ff7a4ab2..7c07ca301 100644 --- a/builtin/bins/provider-aws/main.go +++ b/builtin/bins/provider-aws/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/hashicorp/terraform/builtin/providers/aws" + "github.com/muralimadhu/terraform/builtin/providers/aws" "github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/terraform" ) From 23c3280c1dfb3bddae3b84eb674fc4e52e262c24 Mon Sep 17 00:00:00 2001 From: Madhu Date: Thu, 20 Nov 2014 14:18:14 -0800 Subject: [PATCH 4/4] { --- builtin/bins/provider-aws/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/bins/provider-aws/main.go b/builtin/bins/provider-aws/main.go index 7c07ca301..5ff7a4ab2 100644 --- a/builtin/bins/provider-aws/main.go +++ b/builtin/bins/provider-aws/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/muralimadhu/terraform/builtin/providers/aws" + "github.com/hashicorp/terraform/builtin/providers/aws" "github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/terraform" )