Skip to content

Commit

Permalink
Merge pull request #39 from daidokoro/notification-arns
Browse files Browse the repository at this point in the history
Notification ARNs
  • Loading branch information
daidokoro authored Jan 7, 2020
2 parents 1bfc55c + 512a1d1 commit 7e8ead4
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 31 deletions.
33 changes: 17 additions & 16 deletions commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion commands/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package commands

// Version
const version = "v0.81.2-beta"
const version = "v0.81.3-beta"
2 changes: 1 addition & 1 deletion stacks/clouformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
25 changes: 13 additions & 12 deletions stacks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
5 changes: 5 additions & 0 deletions stacks/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion stacks/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions stacks/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions stacks/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7e8ead4

Please sign in to comment.