diff --git a/aws/resources/sqs.go b/aws/resources/sqs.go index 5d3eb0e4..33ae949b 100644 --- a/aws/resources/sqs.go +++ b/aws/resources/sqs.go @@ -2,6 +2,8 @@ package resources import ( "context" + "strconv" + "time" "github.com/aws/aws-sdk-go/aws" awsgo "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/sqs" @@ -9,7 +11,6 @@ import ( "github.com/gruntwork-io/cloud-nuke/logging" "github.com/gruntwork-io/cloud-nuke/report" "github.com/gruntwork-io/cloud-nuke/telemetry" - "github.com/gruntwork-io/cloud-nuke/util" "github.com/gruntwork-io/go-commons/errors" commonTelemetry "github.com/gruntwork-io/go-commons/telemetry" ) @@ -42,17 +43,17 @@ func (sq *SqsQueue) getAll(c context.Context, configObj config.Config) ([]*strin return nil, errors.WithStackTrace(err) } - // Convert string timestamp to int64 - createdAt := queueAttributes.Attributes["CreatedTimestamp"] - createdAtTime, err := util.ParseTimestamp(createdAt) + // Convert string timestamp to int64 and then to time.Time + createdAt := *queueAttributes.Attributes["CreatedTimestamp"] + createdAtInt, err := strconv.ParseInt(createdAt, 10, 64) if err != nil { return nil, errors.WithStackTrace(err) } + createdAtTime := time.Unix(createdAtInt, 0) - // Compare time as int64 if configObj.SQS.ShouldInclude(config.ResourceValue{ Name: queue, - Time: createdAtTime, + Time: &createdAtTime, }) { urls = append(urls, queue) } @@ -61,7 +62,7 @@ func (sq *SqsQueue) getAll(c context.Context, configObj config.Config) ([]*strin return urls, nil } -// Deletes all Elastic Load Balancers +// Deletes all Queues func (sq *SqsQueue) nukeAll(urls []*string) error { if len(urls) == 0 { logging.Debugf("No SQS Queues to nuke in region %s", sq.Region) diff --git a/aws/resources/sqs_test.go b/aws/resources/sqs_test.go index 488381c3..d68395cf 100644 --- a/aws/resources/sqs_test.go +++ b/aws/resources/sqs_test.go @@ -10,6 +10,7 @@ import ( "github.com/gruntwork-io/cloud-nuke/telemetry" "github.com/stretchr/testify/require" "regexp" + "strconv" "testing" "time" ) @@ -55,12 +56,12 @@ func TestSqsQueue_GetAll(t *testing.T) { GetQueueAttributesOutput: map[string]sqs.GetQueueAttributesOutput{ queue1: { Attributes: map[string]*string{ - "CreatedTimestamp": awsgo.String(now.Format(time.RFC3339)), + "CreatedTimestamp": awsgo.String(strconv.FormatInt(now.Unix(), 10)), }, }, queue2: { Attributes: map[string]*string{ - "CreatedTimestamp": awsgo.String(now.Add(1).Format(time.RFC3339)), + "CreatedTimestamp": awsgo.String(strconv.FormatInt(now.Add(1).Unix(), 10)), }, }, },