DoCreateStackRequest requests the creation of a CloudFormation stack
(ctx context.Context, i *Stack, templateData TemplateData, tags, parameters map[string]string, withIAM bool, withNamedIAM bool)
| 119 | |
| 120 | // DoCreateStackRequest requests the creation of a CloudFormation stack |
| 121 | func (c *StackCollection) DoCreateStackRequest(ctx context.Context, i *Stack, templateData TemplateData, tags, parameters map[string]string, withIAM bool, withNamedIAM bool) error { |
| 122 | input := &cloudformation.CreateStackInput{ |
| 123 | StackName: i.StackName, |
| 124 | DisableRollback: aws.Bool(c.disableRollback), |
| 125 | EnableTerminationProtection: aws.Bool(true), |
| 126 | } |
| 127 | input.Tags = append(input.Tags, c.sharedTags...) |
| 128 | for k, v := range tags { |
| 129 | input.Tags = append(input.Tags, newTag(k, v)) |
| 130 | } |
| 131 | |
| 132 | switch data := templateData.(type) { |
| 133 | case TemplateBody: |
| 134 | input.TemplateBody = aws.String(string(data)) |
| 135 | case TemplateURL: |
| 136 | input.TemplateURL = aws.String(string(data)) |
| 137 | default: |
| 138 | return fmt.Errorf("unknown template data type: %T", templateData) |
| 139 | } |
| 140 | |
| 141 | if withIAM { |
| 142 | input.Capabilities = stackCapabilitiesIAM |
| 143 | } |
| 144 | |
| 145 | if withNamedIAM { |
| 146 | input.Capabilities = stackCapabilitiesNamedIAM |
| 147 | } |
| 148 | |
| 149 | if cfnRole := c.roleARN; cfnRole != "" { |
| 150 | input.RoleARN = aws.String(cfnRole) |
| 151 | } |
| 152 | |
| 153 | for k, v := range parameters { |
| 154 | input.Parameters = append(input.Parameters, types.Parameter{ |
| 155 | ParameterKey: aws.String(k), |
| 156 | ParameterValue: aws.String(v), |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | logger.Debug("CreateStackInput = %#v", input) |
| 161 | s, err := c.cloudformationAPI.CreateStack(ctx, input) |
| 162 | if err != nil { |
| 163 | return fmt.Errorf("creating CloudFormation stack %q: %w", *i.StackName, err) |
| 164 | } |
| 165 | i.StackId = s.StackId |
| 166 | return nil |
| 167 | } |
| 168 | |
| 169 | // CreateStack with given name, stack builder instance and parameters; |
| 170 | // any errors will be written to errs channel, when nil is written, |
no test coverage detected