CDK
AWS CDK support is available now in early access for the Infracost GitHub and GitLab apps, contact hello@infracost.io if you'd like to request access. CLI and IDE support for CDK are on the roadmap for 2026 and we’ll share more as those pieces come together. AutoFix pull requests do not currently work with CDK.
Overview
Infracost parses CDK repos written in Node (TypeScript / JavaScript) and Python. At a high-level, Infracost:
- Automatically detect repos that have CDK, using heuristics such as looking for
cdk.json. Infracost prefers that you supply a completecdk.context.json, co-located withcdk.json. This is best practice. - Install its dependencies by automatically detecting your dependency manifests. Infracost does not build packages from source. We strongly encourage you to commit up-to-date lockfiles, per best practice, as siblings to your package manifests. This lets us resolve packages at the versions you expect, from the sources you defined.
- Run
cdk synthinternally when Infracost processes your repos and pull requests. - Use the generated CloudFormation template from
cdk synthto estimate cloud costs and look for policy failures.
Private package repositories
For GitHub Packages, please generate (in GitHub) a time-unlimited PAT with read:packages and SSO authorization (if relevant to your org). You may wish to use a bot user for this purpose. In the Infracost Cloud dashboard, go to Org Settings > Integrations > GitHub > Settings and set an environment variable called INFRACOST_GITHUB_PACKAGES_TOKEN with the token value.
For Artifactory and other registries, follow this docs section to set your registry host and token in Infracost Cloud.
If you require us to use AWS CodeArtifact with an assumed IAM role, please email support@infracost.io.
Resolving internal endpoints
Some orgs use internal hostnames for their Artifactory (and self-hosted GitHub, etc.) like artifactory.example.internal. These are often mentioned in lockfiles.
Your options are:
- Email support@infracost.io with a map of your internal hostname to a public hostname with internet-routable resolution, e.g.
artifactory.example.internal-->example.jfrog.io. - For AWS users, contact support@infracost.io if you'd like to establish a PrivateLink connection so that Infracost can reach your internal endpoint without using the public internet.
Config file options
By default, Infracost will auto-detect your CDK apps, but it can't auto-detect context values or environment variables you supply during synth. Contact support@infracost.io as we support this via config files, for example in situations when you want to supply:
- Environment variables
- Custom
cdk synth --context foo=barkey-value pairs - Explicit specification of which package manifests Infracost should consider
CDK Stages
Any Stages generated by CDK synth alongside your main CloudFormation templates will be included in our analysis.