DeleteStack deletes a CloudFormation stack
(ctx context.Context)
| 58 | |
| 59 | // DeleteStack deletes a CloudFormation stack |
| 60 | func (s *StackDeployer) DeleteStack(ctx context.Context) error { |
| 61 | stackName := s.getFullStackName() |
| 62 | |
| 63 | log.Printf("Deleting CloudFormation stack: %s", stackName) |
| 64 | |
| 65 | input := &cloudformation.DeleteStackInput{ |
| 66 | StackName: aws.String(stackName), |
| 67 | } |
| 68 | |
| 69 | _, err := s.clients.CloudFormation.DeleteStackWithContext(ctx, input) |
| 70 | if err != nil { |
| 71 | return fmt.Errorf("failed to delete stack: %w", err) |
| 72 | } |
| 73 | |
| 74 | // Wait for deletion to complete |
| 75 | log.Printf("Waiting for stack deletion to complete...") |
| 76 | err = s.waitForStackOperation(ctx, stackName, cloudformation.StackStatusDeleteComplete, 20*time.Minute) |
| 77 | if err != nil { |
| 78 | return fmt.Errorf("stack deletion failed: %w", err) |
| 79 | } |
| 80 | |
| 81 | log.Printf("Stack deleted successfully") |
| 82 | return nil |
| 83 | } |
| 84 | |
| 85 | // GetStackOutputs retrieves outputs from a CloudFormation stack |
| 86 | func (s *StackDeployer) GetStackOutputs(ctx context.Context) (*StackOutput, error) { |
no test coverage detected