in internal/pkg/deploy/cloudformation/component.go [27:66]
func (cf CloudFormation) DeployComponent(component *types.ComponentInput) (*types.Component, error) {
componentConfig := stack.NewComponentStackConfig(component, cf.box)
// Try to create the stack
if _, err := cf.create(componentConfig); err != nil {
var existsErr *ErrStackAlreadyExists
if errors.As(err, &existsErr) {
// Stack already exists, update the stack
deployStarted, err := cf.update(componentConfig)
if err != nil {
return nil, err
}
if deployStarted {
// Wait for the stack to finish updating
stack, err := cf.waitForStackUpdate(componentConfig)
if err != nil {
return nil, err
}
return componentConfig.ToComponent(stack)
} else {
// nothing to deploy
stack, err := cf.describe(componentConfig)
if err != nil {
return nil, err
}
return componentConfig.ToComponent(stack)
}
} else {
return nil, err
}
}
// Wait for the stack to finish creation
stack, err := cf.waitForStackCreation(componentConfig)
if err != nil {
return nil, err
}
return componentConfig.ToComponent(stack)
}