Skip to content

Commit

Permalink
validate #4474
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel committed Nov 27, 2019
1 parent 94a4fe2 commit 04ffee1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/@aws-cdk/core/test/test.stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,59 @@ export = {
test.done();
},

'cross stack references and dependencies work within child stacks (non-nested)'(test: Test) {
// GIVEN
const app = new App();
const parent = new Stack(app, 'Parent');
const child1 = new Stack(parent, 'Child1');
const child2 = new Stack(parent, 'Child2');
const resourceA = new CfnResource(child1, 'ResourceA', { type: 'RA' });
const resourceB = new CfnResource(child1, 'ResourceB', { type: 'RB' });

// WHEN
const resource2 = new CfnResource(child2, 'Resource1', {
type: 'R2',
properties: {
RefToResource1: resourceA.ref
}
});
resource2.addDependsOn(resourceB);

// THEN
const assembly = app.synth();
const parentTemplate = assembly.getStackArtifact(parent.artifactId).template;
const child1Template = assembly.getStackArtifact(child1.artifactId).template;
const child2Template = assembly.getStackArtifact(child2.artifactId).template;

test.deepEqual(parentTemplate, {});
test.deepEqual(child1Template, {
Resources: {
ResourceA: { Type: 'RA' } ,
ResourceB: { Type: 'RB' }
},
Outputs: {
ExportsOutputRefResourceA461B4EF9: {
Value: { Ref: 'ResourceA' },
Export: { Name: 'ParentChild18FAEF419:Child1ExportsOutputRefResourceA7BF20B37' }
}
}
});
test.deepEqual(child2Template, {
Resources: {
Resource1: {
Type: 'R2',
Properties: {
RefToResource1: { 'Fn::ImportValue': 'ParentChild18FAEF419:Child1ExportsOutputRefResourceA7BF20B37' }
}
}
}
});

test.deepEqual(assembly.getStackArtifact(child1.artifactId).dependencies.map(x => x.id), []);
test.deepEqual(assembly.getStackArtifact(child2.artifactId).dependencies.map(x => x.id), [ 'ParentChild18FAEF419' ]);
test.done();
},

'CfnSynthesisError is ignored when preparing cross references'(test: Test) {
// GIVEN
const app = new App();
Expand Down

0 comments on commit 04ffee1

Please sign in to comment.