How to turn off Metadata Reporting in AWS CDK

avatar
Borislav Hadzhiev

2 min

banner

# Turn off CDK Metadata globally

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:

cdk.json
{ "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:

cdk out no metadata

Also if we issue the cdk synth command we won't see the CDKMetadata section anymore:

cdk synth no metadata

# Turn off Metadata for a single command

We can also opt out of metadata reporting for a single command, by adding the --no-version-reporting flag to the cdk deploy command:

shell
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.

# What is Metadata

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:

cdk.out/my-cdk-stack.template.json
{ "CDKMetadata": { "Type": "AWS::CDK::Metadata", "Properties": { "Analytics": "v2:deflate64:H4sIAAAA..." }, "Metadata": { "aws:cdk:path": "my-cdk-stack/CDKMetadata/Default" } } }

cdk out metadata

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.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.