From 1af68c1ef81ebc24def9761405115b2253fadd4a Mon Sep 17 00:00:00 2001 From: Ina Stoyanova Date: Thu, 8 Oct 2020 13:04:52 +0100 Subject: [PATCH] extracting to a globals.go file & updating eip & ecs to reference it --- aws/ecs_cluster.go | 2 -- aws/eip.go | 5 ++--- aws/globals.go | 3 +++ 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 aws/globals.go diff --git a/aws/ecs_cluster.go b/aws/ecs_cluster.go index 1959612f..3d023806 100644 --- a/aws/ecs_cluster.go +++ b/aws/ecs_cluster.go @@ -11,8 +11,6 @@ import ( "github.com/gruntwork-io/gruntwork-cli/errors" ) -const firstSeenTagKey = "cloud-nuke-first-seen" - // Tag an ECS cluster identified by the given cluster ARN with a tag that has the given key and value func tagEcsCluster(awsSession *session.Session, clusterArn *string, tagKey string, tagValue string) error { svc := ecs.New(awsSession) diff --git a/aws/eip.go b/aws/eip.go index 68c40236..ca11bc57 100644 --- a/aws/eip.go +++ b/aws/eip.go @@ -49,7 +49,6 @@ func getFirstSeenTag(svc *ec2.EC2, address ec2.Address, key string, layout strin // Returns a formatted string of EIP allocation ids func getAllEIPAddresses(session *session.Session, region string, excludeAfter time.Time) ([]*string, error) { svc := ec2.New(session) - const key = "cloud-nuke-first-seen" const layout = "2006-01-02 15:04:05" result, err := svc.DescribeAddresses(&ec2.DescribeAddressesInput{}) @@ -59,7 +58,7 @@ func getAllEIPAddresses(session *session.Session, region string, excludeAfter ti var allocationIds []*string for _, address := range result.Addresses { - firstSeenTime, err := getFirstSeenTag(svc, *address, key, layout) + firstSeenTime, err := getFirstSeenTag(svc, *address, firstSeenTagKey, layout) if err != nil { return nil, errors.WithStackTrace(err) } @@ -67,7 +66,7 @@ func getAllEIPAddresses(session *session.Session, region string, excludeAfter ti if firstSeenTime == nil { now := time.Now().UTC() firstSeenTime = &now - if err := setFirstSeenTag(svc, *address, key, *firstSeenTime, layout); err != nil { + if err := setFirstSeenTag(svc, *address, firstSeenTagKey, *firstSeenTime, layout); err != nil { return nil, err } } diff --git a/aws/globals.go b/aws/globals.go new file mode 100644 index 00000000..2b29868b --- /dev/null +++ b/aws/globals.go @@ -0,0 +1,3 @@ +package aws + +const firstSeenTagKey = "cloud-nuke-first-seen"