MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / CreateStack

Function CreateStack

go/example_code/cloudformation/CfnCrudOps.go:18–40  ·  view source on GitHub ↗

CreateStack creates a CloudFormation stack

(sess *session.Session, stackName string, template string)

Source from the content-addressed store, hash-verified

16
17// CreateStack creates a CloudFormation stack
18func CreateStack(sess *session.Session, stackName string, template string) error {
19 svc := cloudformation.New(sess)
20 // Open file template
21 // Get entire file as a string
22 content, err := ioutil.ReadFile(template)
23 if err != nil {
24 return err
25 }
26
27 // Convert []byte to string
28 templateBody := string(content)
29
30 input := &cloudformation.CreateStackInput{TemplateBody: aws.String(templateBody), StackName: aws.String(stackName)}
31
32 _, err = svc.CreateStack(input)
33 if err != nil {
34 return err
35 }
36
37 // Wait until stack is created
38 desInput := &cloudformation.DescribeStacksInput{StackName: aws.String(stackName)}
39 return svc.WaitUntilStackCreateComplete(desInput)
40}
41
42// GetStackSummaries gets a list of summary information about all stacks or those with status
43func GetStackSummaries(sess *session.Session, status string) ([]*cloudformation.StackSummary, error) {

Callers 2

TestCfnCrudOpsFunction · 0.70
mainFunction · 0.70

Calls 2

CreateStackMethod · 0.80
StringMethod · 0.45

Tested by 1

TestCfnCrudOpsFunction · 0.56