@@ -3,7 +3,6 @@ package resources
33import (
44 "context"
55 "errors"
6- "log"
76 "net"
87 "strconv"
98 "time"
@@ -14,7 +13,8 @@ import (
1413 "github.com/aws/aws-sdk-go-v2/service/autoscaling"
1514 "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
1615 "github.com/aws/aws-sdk-go-v2/service/ec2"
17- ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
16+
17+ "github.com/sirupsen/logrus"
1818
1919 "terraform-provider-iterative/task/aws/client"
2020 "terraform-provider-iterative/task/common"
@@ -93,7 +93,7 @@ func (a *AutoScalingGroup) Create(ctx context.Context) error {
9393 AutoScalingGroupNames : []string {a .Identifier },
9494 }
9595
96- if err := autoscaling .NewGroupInServiceWaiter (a .Client .Services .AutoScaling ).Wait (ctx , & waitInput , a .Client .Cloud .Timeouts .Create ); err != nil {
96+ if err := autoscaling .NewGroupExistsWaiter (a .Client .Services .AutoScaling ).Wait (ctx , & waitInput , a .Client .Cloud .Timeouts .Create ); err != nil {
9797 return err
9898 }
9999
@@ -134,7 +134,7 @@ func (a *AutoScalingGroup) Read(ctx context.Context) error {
134134 if instance .StateReason != nil {
135135 status += " " + aws .ToString (instance .StateReason .Message )
136136 }
137- log . Println ( "[DEBUG] AutoScaling Group State:" , status )
137+ logrus . Debug ( " AutoScaling Group State:" , status )
138138 if status == "running" {
139139 a .Attributes .Status [common .StatusCodeActive ]++
140140 }
@@ -209,16 +209,11 @@ func (a *AutoScalingGroup) Delete(ctx context.Context) error {
209209 return err
210210 }
211211
212- waitInput := ec2.DescribeInstancesInput {
213- Filters : []ec2types.Filter {
214- {
215- Name : aws .String ("tag:Name" ),
216- Values : []string {a .Dependencies .LaunchTemplate .Identifier },
217- },
218- },
212+ waitInput := autoscaling.DescribeAutoScalingGroupsInput {
213+ AutoScalingGroupNames : []string {a .Identifier },
219214 }
220215
221- if err := ec2 . NewInstanceTerminatedWaiter (a .Client .Services .EC2 ).Wait (ctx , & waitInput , a .Client .Cloud .Timeouts .Delete ); err != nil {
216+ if err := autoscaling . NewGroupNotExistsWaiter (a .Client .Services .AutoScaling ).Wait (ctx , & waitInput , a .Client .Cloud .Timeouts .Delete ); err != nil {
222217 return err
223218 }
224219
0 commit comments