MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / GetCloudFormationTemplate

Function GetCloudFormationTemplate

internal/deploy/templates.go:22–48  ·  view source on GitHub ↗

GetCloudFormationTemplate returns the CloudFormation template content

(cfg *config.CLIConfig, customTemplatePath string)

Source from the content-addressed store, hash-verified

20
21// GetCloudFormationTemplate returns the CloudFormation template content
22func GetCloudFormationTemplate(cfg *config.CLIConfig, customTemplatePath string) (string, error) {
23 var templateContent string
24
25 // Use custom template file if provided
26 if customTemplatePath != "" {
27 content, err := os.ReadFile(customTemplatePath)
28 if err != nil {
29 return "", fmt.Errorf("failed to read custom template file %s: %w", customTemplatePath, err)
30 }
31 templateContent = string(content)
32 } else {
33 // Use embedded template
34 templateContent = embeddedTemplate
35 }
36
37 // Perform parameter substitution
38 params := TemplateParams{
39 StackName: cfg.Deployment.StackName,
40 }
41
42 substitutedTemplate, err := substituteTemplateParams(templateContent, params)
43 if err != nil {
44 return "", fmt.Errorf("failed to substitute template parameters: %w", err)
45 }
46
47 return substitutedTemplate, nil
48}
49
50// substituteTemplateParams performs basic parameter substitution in the template
51func substituteTemplateParams(templateContent string, params TemplateParams) (string, error) {

Calls 1

substituteTemplateParamsFunction · 0.85