func()

in internal/pkg/deploy/cloudformation/component.go [116:135]


func (cf CloudFormation) DeleteComponent(component *types.ComponentInput) (*types.Component, error) {
	stackConfig := stack.NewComponentStackConfig(component, cf.box)
	stack, err := cf.describe(stackConfig)
	if err != nil {
		var notFoundErr *ErrStackNotFound
		if errors.As(err, &notFoundErr) {
			// Stack was not found, don't return an error, since it's deleted already
			return &types.Component{
				StackName: stackConfig.StackName(),
			}, nil
		} else {
			return nil, err
		}
	}
	err = cf.delete(*stack.StackId)
	if err != nil {
		return nil, err
	}
	return stackConfig.ToComponent(stack)
}