From 544d0435733da07501e598605e1db35d1b4b043b Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 00:44:32 +0000 Subject: [PATCH 1/7] added notification-arn property to the stack type --- stacks/stack.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stacks/stack.go b/stacks/stack.go index f896761..347c6dc 100644 --- a/stacks/stack.go +++ b/stacks/stack.go @@ -62,6 +62,9 @@ type Stack struct { // has been passed explicitly as an arguement and // should be processed Actioned bool + + // list of SNS notification ARNs + NotificationARNs []string } // SetStackName - sets the stackname with struct From 64a581d3924a90332ca4e5e71c0204270687c123 Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 00:45:47 +0000 Subject: [PATCH 2/7] added notification-arn to stack map loading --- commands/config.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/commands/config.go b/commands/config.go index 91281f9..7ed8daf 100644 --- a/commands/config.go +++ b/commands/config.go @@ -51,22 +51,23 @@ func Configure(confSource string, conf string) (err error) { // Get Stack Values for s, v := range config.Stacks { stacks.Add(s, &stks.Stack{ - Name: s, - Profile: v.Profile, - Region: v.Region, - DependsOn: v.DependsOn, - Policy: v.Policy, - Source: v.Source, - Stackname: v.Name, - Bucket: v.Bucket, - Role: v.Role, - DeployDelims: &config.DeployDelimiter, - GenDelims: &config.GenerateDelimiter, - TemplateValues: config.Vars(), - GenTimeFunc: &GenTimeFunctions, - DeployTimeFunc: &DeployTimeFunctions, - Project: &config.Project, - Timeout: v.Timeout, + Name: s, + Profile: v.Profile, + Region: v.Region, + DependsOn: v.DependsOn, + Policy: v.Policy, + Source: v.Source, + Stackname: v.Name, + Bucket: v.Bucket, + Role: v.Role, + DeployDelims: &config.DeployDelimiter, + GenDelims: &config.GenerateDelimiter, + TemplateValues: config.Vars(), + GenTimeFunc: &GenTimeFunctions, + DeployTimeFunc: &DeployTimeFunctions, + Project: &config.Project, + Timeout: v.Timeout, + NotificationARNs: v.NotificationARNs, }) stacks.MustGet(s).SetStackName() From 3aa36585c2e427a914973b6b6597827869b7f0b6 Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 00:46:17 +0000 Subject: [PATCH 3/7] cosmetic update to function loops --- stacks/clouformation.go | 2 +- stacks/helpers.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stacks/clouformation.go b/stacks/clouformation.go index 19124c6..76c280b 100644 --- a/stacks/clouformation.go +++ b/stacks/clouformation.go @@ -202,7 +202,7 @@ func TerminateHandler(m *Map) { m.Range(func(k string, stk *Stack) bool { if utils.StringIn(s.Name, stk.DependsOn) { Log.Info("[%s]: Depends on [%s].. Waiting for dependency to terminate", stk.Name, s.Name) - for _ = range tick.C { + for range tick.C { if !stk.StackExists() { break } diff --git a/stacks/helpers.go b/stacks/helpers.go index 26bb2e6..c9782b1 100644 --- a/stacks/helpers.go +++ b/stacks/helpers.go @@ -53,7 +53,7 @@ func Wait(getStatus func(s ...string) (string, error), args ...string) error { var stat string var err error - for _ = range tick.C { + for range tick.C { if len(args) > 0 { stat, err = getStatus(args[0]) } else { From 52f8716694bef1b8dff848754de0ba8793fed9db Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 00:46:59 +0000 Subject: [PATCH 4/7] added notification-arns to config type --- stacks/config.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/stacks/config.go b/stacks/config.go index 4c2fe16..4bf6ce0 100644 --- a/stacks/config.go +++ b/stacks/config.go @@ -19,18 +19,19 @@ type Config struct { DeployDelimiter string `yaml:"deploy_time,omitempty" json:"deploy_time,omitempty" hcl:"deploy_time,omitempty"` Global map[string]interface{} `yaml:"global,omitempty" json:"global,omitempty" hcl:"global,omitempty"` Stacks map[string]struct { - DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty" hcl:"depends_on,omitempty"` - Parameters []map[string]string `yaml:"parameters,omitempty" json:"parameters,omitempty" hcl:"parameters,omitempty"` - Policy string `yaml:"policy,omitempty" json:"policy,omitempty" hcl:"policy,omitempty"` - Profile string `yaml:"profile,omitempty" json:"profile,omitempty" hcl:"profile,omitempty"` - Region string `yaml:"region,omitempty" json:"region,omitempty" hcl:"region,omitempty"` - Source string `yaml:"source,omitempty" json:"source,omitempty" hcl:"source,omitempty"` - Name string `yaml:"name,omitempty" json:"name,omitempty" hcl:"name,omitempty"` - Bucket string `yaml:"bucket,omitempty" json:"bucket,omitempty" hcl:"bucket,omitempty"` - Role string `yaml:"role,omitempty" json:"role,omitempty" hcl:"role,omitempty"` - Tags []map[string]string `yaml:"tags,omitempty" json:"tags,omitempty" hcl:"tags,omitempty"` - Timeout int64 `yaml:"timeout,omitempty" json:"timeout,omitempty" hcl:"timeout,omitempty"` - CF map[string]interface{} `yaml:"cf,omitempty" json:"cf,omitempty" hcl:"cf,omitempty"` + DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty" hcl:"depends_on,omitempty"` + Parameters []map[string]string `yaml:"parameters,omitempty" json:"parameters,omitempty" hcl:"parameters,omitempty"` + Policy string `yaml:"policy,omitempty" json:"policy,omitempty" hcl:"policy,omitempty"` + Profile string `yaml:"profile,omitempty" json:"profile,omitempty" hcl:"profile,omitempty"` + Region string `yaml:"region,omitempty" json:"region,omitempty" hcl:"region,omitempty"` + Source string `yaml:"source,omitempty" json:"source,omitempty" hcl:"source,omitempty"` + Name string `yaml:"name,omitempty" json:"name,omitempty" hcl:"name,omitempty"` + Bucket string `yaml:"bucket,omitempty" json:"bucket,omitempty" hcl:"bucket,omitempty"` + Role string `yaml:"role,omitempty" json:"role,omitempty" hcl:"role,omitempty"` + Tags []map[string]string `yaml:"tags,omitempty" json:"tags,omitempty" hcl:"tags,omitempty"` + Timeout int64 `yaml:"timeout,omitempty" json:"timeout,omitempty" hcl:"timeout,omitempty"` + NotificationARNs []string `yaml:"notification-arns" json:"notification-arns" hcl:"notification-arns"` + CF map[string]interface{} `yaml:"cf,omitempty" json:"cf,omitempty" hcl:"cf,omitempty"` } `yaml:"stacks" json:"stacks" hcl:"stacks"` } From 971045c9d8dc4c0db348fd2b69c036b3221821a5 Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 00:47:32 +0000 Subject: [PATCH 5/7] added notification-arn set to deploy function --- stacks/deploy.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stacks/deploy.go b/stacks/deploy.go index 3c4c689..5edb61d 100644 --- a/stacks/deploy.go +++ b/stacks/deploy.go @@ -56,6 +56,11 @@ func (s *Stack) Deploy() error { createParams.TimeoutInMinutes = aws.Int64(s.Timeout) } + // add notification arns + if len(s.NotificationARNs) > 0 { + createParams.NotificationARNs = aws.StringSlice(s.NotificationARNs) + } + // If IAM is being touched, add Capabilities if strings.Contains(s.Template, "AWS::IAM") { createParams.Capabilities = []*string{ From 410c935d2a4161bf770b4af9f5ed1b18f79ee167 Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 01:00:06 +0000 Subject: [PATCH 6/7] add version bump --- commands/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/version.go b/commands/version.go index 4c52739..79b8979 100644 --- a/commands/version.go +++ b/commands/version.go @@ -1,4 +1,4 @@ package commands // Version -const version = "v0.81.2-beta" +const version = "v0.81.3-beta" From 512a1d11764a15520daab2bdb0e094aa4c24d090 Mon Sep 17 00:00:00 2001 From: Shaun Remekie Date: Mon, 6 Jan 2020 01:02:45 +0000 Subject: [PATCH 7/7] added notification arns to stack update --- stacks/update.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stacks/update.go b/stacks/update.go index 55bfec0..ee5195e 100644 --- a/stacks/update.go +++ b/stacks/update.go @@ -36,6 +36,10 @@ func (s *Stack) Update() error { updateParams.Tags = s.Tags } + if len(s.NotificationARNs) > 0 { + updateParams.NotificationARNs = aws.StringSlice(s.NotificationARNs) + } + // If bucket - upload to s3 if s.Bucket != "" { exists, err := bucket.Exists(s.Bucket, s.Session)