/
forge.go
44 lines (41 loc) · 1.21 KB
/
forge.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package forgelib
import "github.com/aws/aws-sdk-go/service/cloudformation"
// Stack represents the attributes of a stack deployment, including the AWS
// parameters, and local resources which represent what needs to be deployed
type Stack struct {
ParameterBodies []string
ParameterOverrides map[string]string
ProjectManifest string
CfnRoleName string
StackID string
StackInfo *cloudformation.Stack
StackName string
StackPolicyBody string
TagsBody string
TemplateBody string
TerminationProtection bool
}
// GetStackInfo populates the StackInfo for this object from the existing stack
// found in the environment
func (s *Stack) GetStackInfo() (err error) {
var stackName *string
if s.StackID != "" {
stackName = &s.StackID
} else if s.StackName != "" {
stackName = &s.StackName
} else {
return errorNoStackNameOrID
}
stackOut, err := cfnClient.DescribeStacks(&cloudformation.DescribeStacksInput{StackName: stackName})
if err != nil {
return err
}
s.StackInfo = stackOut.Stacks[0]
if s.StackName == "" {
s.StackName = *s.StackInfo.StackName
}
if s.StackID == "" {
s.StackID = *s.StackInfo.StackId
}
return
}