From 45d318f5735da38dca511b7d123ed113153167e3 Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Thu, 10 Jul 2014 15:41:06 -0400 Subject: [PATCH] providers/aws: destroy for autoscaling and launch conf --- .../aws/resource_aws_autoscaling_group.go | 21 +++++++++---------- .../aws/resource_aws_launch_configuration.go | 16 +++++++++++--- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group.go b/builtin/providers/aws/resource_aws_autoscaling_group.go index c4480ac20..ade118b37 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group.go @@ -102,21 +102,20 @@ func resource_aws_autoscaling_group_update( func resource_aws_autoscaling_group_destroy( s *terraform.ResourceState, meta interface{}) error { - // p := meta.(*ResourceProvider) - // autoscalingconn := p.autoscalingconn + p := meta.(*ResourceProvider) + autoscalingconn := p.autoscalingconn log.Printf("[DEBUG] autoscaling Group destroy: %v", s.ID) - // err := nil + _, err := autoscalingconn.DeleteAutoScalingGroup(&autoscaling.DeleteAutoScalingGroup{Name: s.ID}) - // _, err := autoscalingconn.DeleteAutoScalingGroup(autoscaling.autoscalingGroup{Id: s.ID}) - - // if err != nil { - // autoscalingerr, ok := err.(*autoscaling.Error) - // if ok && autoscalingerr.Code == "InvalidGroup.NotFound" { - // return nil - // } - // } + if err != nil { + autoscalingerr, ok := err.(*autoscaling.Error) + if ok && autoscalingerr.Code == "InvalidGroup.NotFound" { + return nil + } + return err + } return nil } diff --git a/builtin/providers/aws/resource_aws_launch_configuration.go b/builtin/providers/aws/resource_aws_launch_configuration.go index 1a4392198..2fff7294e 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration.go +++ b/builtin/providers/aws/resource_aws_launch_configuration.go @@ -85,10 +85,20 @@ func resource_aws_launch_configuration_update( func resource_aws_launch_configuration_destroy( s *terraform.ResourceState, meta interface{}) error { - // p := meta.(*ResourceProvider) - // autoscalingconn := p.autoscalingconn + p := meta.(*ResourceProvider) + autoscalingconn := p.autoscalingconn - log.Printf("[DEBUG] launch configuration destroy: %v", s.ID) + log.Printf("[DEBUG] Launch Configuration destroy: %v", s.ID) + + _, err := autoscalingconn.DeleteLaunchConfiguration(&autoscaling.DeleteLaunchConfiguration{Name: s.ID}) + + if err != nil { + autoscalingerr, ok := err.(*autoscaling.Error) + if ok && autoscalingerr.Code == "InvalidConfiguration.NotFound" { + return nil + } + return err + } return nil }