in internal/pkg/deploy/cloudformation/component.go [68:103]
func (cf CloudFormation) DryRunComponent(component *types.ComponentInput) (string, error) {
stackConfig := stack.NewComponentStackConfig(component, cf.box)
template, err := stackConfig.Template()
if err != nil {
return "", fmt.Errorf("template creation: %w", err)
}
templateFileDir := filepath.Join(".", templateFileDirectoryName)
if _, err := os.Stat(templateFileDir); os.IsNotExist(err) {
err = os.Mkdir(templateFileDir, os.ModePerm)
if err != nil {
return "", fmt.Errorf("could not create directory %s: %w", templateFileDir, err)
}
}
templateFileAbsDir, err := filepath.Abs(templateFileDir)
if err != nil {
return "", fmt.Errorf("could not get absolute path for directory %s: %w", templateFileDir, err)
}
templateFilePath := filepath.Join(templateFileAbsDir, stackConfig.StackName()+"-template.yaml")
f, err := os.Create(templateFilePath)
if err != nil {
return "", err
}
defer f.Close()
_, err = f.WriteString(template)
if err != nil {
return "", err
}
f.Sync()
return templateFilePath, nil
}