Skip to content

Commit

Permalink
guard against users accidentally omitting 'render:' on templates
Browse files Browse the repository at this point in the history
If the template has '$imports' in it but
  Template: cfn-template.yaml
in the stack-args.yaml, warn that it should be
  Template: render:cfn-template.yaml
  • Loading branch information
tavisrudd committed Aug 23, 2017
1 parent 160e412 commit 05afb58
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cfn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,16 @@ Promise<{TemplateBody?: string, TemplateURL?: string}> {
if (_.isUndefined(location)) {
return {};
}
const shouldRender = (location.trim().indexOf('render:') === 0);
const importData = await readFromImportLocation(location.trim().replace(/^ *render:/, ''), baseLocation);
const shouldRender = (location.trim().indexOf('render:') === 0);
if (!shouldRender && importData.data.indexOf('$imports:') > -1) {
throw new Error(
`Your cloudformation Template from ${location} appears to`
+ ' use iidy\'s yaml pre-processor syntax.\n'
+ ' You need to prefix the template location with "render:".\n'
+ ` e.g. Template: "render:${location}"`
);
}
if (!shouldRender && importData.importType === 's3') {
return {TemplateURL: importData.resolvedLocation};
} else {
Expand Down

0 comments on commit 05afb58

Please sign in to comment.