Skip to content

Commit 0c0e049

Browse files
corymhalljosephedward
authored andcommitted
chore(cli): add integ test for asset bundling in a stage (aws#21294)
We recently had an issue where a PR broke asset bundling for stacks that were created under a stage. This PR adds an integration test that deploys a Stack under a Stage that contains lambda function with an asset. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 95aa449 commit 0c0e049

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/aws-cdk/test/integ/cli/app/app.js

100644100755
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,19 @@ class ConditionalResourceStack extends cdk.Stack {
308308
}
309309
}
310310

311+
class BundlingStage extends cdk.Stage {
312+
constructor(parent, id, props) {
313+
super(parent, id, props);
314+
const stack = new cdk.Stack(this, 'BundlingStack');
315+
316+
new lambda.Function(stack, 'Handler', {
317+
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')),
318+
handler: 'index.handler',
319+
runtime: lambda.Runtime.NODEJS_16_X,
320+
});
321+
}
322+
}
323+
311324
class SomeStage extends cdk.Stage {
312325
constructor(parent, id, props) {
313326
super(parent, id, props);
@@ -392,6 +405,8 @@ switch (stackSet) {
392405
new BuiltinLambdaStack(app, `${stackPrefix}-builtin-lambda-function`);
393406

394407
new ImportableStack(app, `${stackPrefix}-importable-stack`);
408+
409+
new BundlingStage(app, `${stackPrefix}-bundling-stage`);
395410
break;
396411

397412
case 'stage-using-context':

packages/aws-cdk/test/integ/cli/cli.integtest.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ integTest('Construct with builtin Lambda function', withDefaultFixture(async (fi
6161
await fixture.cdkDestroy('builtin-lambda-function');
6262
}));
6363

64+
// this is to ensure that asset bundling for apps under a stage does not break
65+
integTest('Stage with bundled Lambda function', withDefaultFixture(async (fixture) => {
66+
await fixture.cdkDeploy('bundling-stage/BundlingStack');
67+
fixture.log('Setup complete!');
68+
await fixture.cdkDestroy('bundling-stage/BundlingStack');
69+
}));
70+
6471
integTest('Two ways of showing the version', withDefaultFixture(async (fixture) => {
6572
const version1 = await fixture.cdk(['version'], { verbose: false });
6673
const version2 = await fixture.cdk(['--version'], { verbose: false });

0 commit comments

Comments
 (0)