From 05052d25a70497b70ec0a0b05df12eee7f030446 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 29 May 2018 12:42:27 -0400 Subject: [PATCH] Fix refactoring error --- .gitignore | 2 ++ Makefile | 6 ++++++ main.go | 19 ++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index f1c181e..fe7141b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +aws-hostname \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..455a630 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +export GOOS=linux + +BIN=aws-hostname + +$(BIN): main.go + go build -o $(BIN) main.go \ No newline at end of file diff --git a/main.go b/main.go index 7e1a570..d8363c9 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,24 @@ func main() { } if setEc2Tag { - writeTag(identity.InstanceID, "Name", *hostname) + svc := ec2.New(session.New()) + + input := &ec2.CreateTagsInput{ + Resources: []*string{ + aws.String(identity.InstanceID), + }, + Tags: []*ec2.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(*hostname), + }, + }, + } + + _, err := svc.CreateTags(input) + if err != nil { + log.Fatal(err) + } } if setHostname {