Reading time·2 min
To shave off a couple of lines from our CloudFormation templates, we can opt of our metadata reporting.
Metadata is used by the CDK team in order to collect analytics in regard to how developers use the CDK service.
If we want to disable version reporting for all commands we issue on the CDK
app level, we can edit the contents of our cdk.json
file and set the
versionReporting
key to false
:
{ "app": "npx ts-node --prefer-ts-exts infra/app.ts", "versionReporting": false }
If we now check the contents of the
CloudFormation template in the
cdk.out
directory, we can see that the CDKMetadata
section has been removed:
Also if we issue the cdk synth command we won't
see the CDKMetadata
section anymore:
We can also opt out of metadata reporting for a single command, by adding
the --no-version-reporting
flag to the cdk deploy
command:
npx aws-cdk --no-version-reporting deploy
By taking the --no-version-reporting
flag approach you would have to include
the flag every time you issue a synth
or deploy
command, so the
versionReporting
boolean in the cdk.json
file is the more convenient option.
Metadata is a CloudFormation feature that allows us to specify additional details about our template using JSON or YAML.
Metadata is used by the CDK team in order to collect analytics in regard to how developers use the CDK service.
When we run the cdk synth
command we see the CloudFormation template
equivalent to our CDK code.
At the bottom of the template, we can see the CDKMetadata
section that looks
something like:
CDKMetadata: Type: AWS::CDK::Metadata Properties: Analytics: v2:deflate64:H4sIAAAAAAA... Metadata: aws:cdk:path: my-cdk-stack/CDKMetadata/Default
If we look at the CloudFormation template stored in the cdk.out
directory, we
can also see the CDKMetadata
section:
{ "CDKMetadata": { "Type": "AWS::CDK::Metadata", "Properties": { "Analytics": "v2:deflate64:H4sIAAAA..." }, "Metadata": { "aws:cdk:path": "my-cdk-stack/CDKMetadata/Default" } } }
According to the docs, the CDK team collects data about what constructs developers use in order to gain insight and notify customers who are using constructs with security vulnerabilities.
You can learn more about the related topics by checking out the following tutorials: