Skip to content

Commit

Permalink
add case for when DependsOn is an array. add similar logic to handle …
Browse files Browse the repository at this point in the history
…Condition attribute
  • Loading branch information
dannosaur authored and tavisrudd committed Dec 6, 2019
1 parent 9222fb0 commit 375547b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/preprocess/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,21 @@ export class Visitor {
return _.fromPairs(
_flatten( // as we may output > 1 resource for each template
_.map(_.toPairs(node), ([name, resource]) => {
if (_.has(resource, 'Condition')) {
resource.Condition = this.maybeRewriteRef(
resource.Condition, appendPath(path, 'Condition'), env);
}
if (_.has(resource, 'DependsOn')) {
resource.DependsOn = this.maybeRewriteRef(
resource.DependsOn, appendPath(path, 'DependsOn'), env);
if (_.isArray(resource.DependsOn)) {
const subPath = appendPath(path, 'DependsOn');
resource.DependsOn = _.map(resource.DependsOn, (item: any, idx: number) => {
return this.maybeRewriteRef(item, appendPath(subPath, idx.toString()), env);
});
}
else {
resource.DependsOn = this.maybeRewriteRef(
resource.DependsOn, appendPath(path, 'DependsOn'), env);
}
}
if (_.has(env.$envValues, resource.Type)) {
return this.visitCustomResource(name, resource, path, env);
Expand Down

0 comments on commit 375547b

Please sign in to comment.