Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

feat(cli-integ): add new test to output annotations as objects with tokens #43

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const cdk = require('aws-cdk-lib/core');
const iam = require('aws-cdk-lib/aws-iam');
const sqs = require('aws-cdk-lib/aws-sqs');

const stackPrefix = process.env.STACK_NAME_PREFIX;
if (!stackPrefix) {
throw new Error(`the STACK_NAME_PREFIX environment variable is required`);
}

class TestStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props);
const queue = new sqs.Queue(this, 'queue', {
visibilityTimeout: cdk.Duration.seconds(300),
});
const role = new iam.Role(this, 'role', {
assumedBy: new iam.AccountRootPrincipal(),
});
queue.grantConsumeMessages(role);
}
}

const app = new cdk.App();
const stack = new TestStack(app, `${stackPrefix}-annotations`);
cdk.Annotations.of(stack).addInfo(`stackId: ${stack.stackId}`); // `stack.stackId` is a token

app.synth();
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"app": "node app.js",
"versionReporting": false,
"context": {
"aws-cdk:enableDiffNoFail": "true"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2967,3 +2967,13 @@ integTest('requests go through a proxy when configured',
}
}),
);

integTest(
'output Annotations as objects with tokens',
withSpecificFixture('annotations-app', async (fixture) => {
const synthOutput = await fixture.cdk(['synth', fixture.fullStackName('annotations')], {
captureStderr: true,
});
expect(synthOutput).toContain('{"Fn::Join":["",["stackId: ",{"Ref":"AWS::StackId"}]]}');
}),
);
Loading