(ctx context.Context, stackName, templateBody string, parameters []*cloudformation.Parameter)
| 114 | } |
| 115 | |
| 116 | func (s *StackDeployer) createStack(ctx context.Context, stackName, templateBody string, parameters []*cloudformation.Parameter) (*StackOutput, error) { |
| 117 | log.Printf("Creating new stack...") |
| 118 | |
| 119 | input := &cloudformation.CreateStackInput{ |
| 120 | StackName: aws.String(stackName), |
| 121 | TemplateBody: aws.String(templateBody), |
| 122 | Parameters: parameters, |
| 123 | Capabilities: []*string{ |
| 124 | aws.String(cloudformation.CapabilityCapabilityNamedIam), |
| 125 | }, |
| 126 | Tags: []*cloudformation.Tag{ |
| 127 | { |
| 128 | Key: aws.String("Project"), |
| 129 | Value: aws.String("lambda-nat-proxy"), |
| 130 | }, |
| 131 | { |
| 132 | Key: aws.String("Component"), |
| 133 | Value: aws.String("cloudformation-stack"), |
| 134 | }, |
| 135 | { |
| 136 | Key: aws.String("ManagedBy"), |
| 137 | Value: aws.String("lambda-nat-proxy-cli"), |
| 138 | }, |
| 139 | { |
| 140 | Key: aws.String("Environment"), |
| 141 | Value: aws.String("production"), |
| 142 | }, |
| 143 | { |
| 144 | Key: aws.String("CostCenter"), |
| 145 | Value: aws.String("lambda-nat-proxy"), |
| 146 | }, |
| 147 | { |
| 148 | Key: aws.String("Owner"), |
| 149 | Value: aws.String("lambda-nat-proxy-cli"), |
| 150 | }, |
| 151 | { |
| 152 | Key: aws.String("Mode"), |
| 153 | Value: aws.String(string(s.cfg.Deployment.Mode)), |
| 154 | }, |
| 155 | }, |
| 156 | } |
| 157 | |
| 158 | result, err := s.clients.CloudFormation.CreateStackWithContext(ctx, input) |
| 159 | if err != nil { |
| 160 | return nil, fmt.Errorf("failed to create stack: %w", err) |
| 161 | } |
| 162 | |
| 163 | log.Printf("Stack creation initiated. Stack ID: %s", *result.StackId) |
| 164 | |
| 165 | // Wait for creation to complete |
| 166 | log.Printf("Waiting for stack creation to complete...") |
| 167 | err = s.waitForStackOperation(ctx, stackName, cloudformation.StackStatusCreateComplete, 10*time.Minute) |
| 168 | if err != nil { |
| 169 | return nil, fmt.Errorf("stack creation failed: %w", err) |
| 170 | } |
| 171 | |
| 172 | log.Printf("Stack created successfully") |
| 173 | return s.GetStackOutputs(ctx) |
no test coverage detected