This command lets you upload Terraform runtime artifacts (plan and state JSON files) to the Datadog CI intake endpoint for enhanced cloud-to-code mapping and policy evaluation.
datadog-ci terraform upload [plan|state] <path/to/terraform-file.json> [additional-files...]planorstate: The type of Terraform artifact being uploaded<path>: Path to one or more Terraform JSON files (space-separated)
--repo-id(optional): Repository identifier override (e.g., github.com/datadog/my-repo)--dry-run(default:false): Run the command without uploading any data to Datadog--verbose(default:false): Enable verbose logging--skip-git-metadata-upload(default:false): Skip the upload of git metadata
The following environment variables are required:
DD_API_KEY: the API key to use
Optional environment variables:
DD_SITE: the Datadog site (default:datadoghq.com)DD_GIT_REPOSITORY_URL: Override for repository URLDD_REPOSITORY_URL: Alternative override for repository URL
# Upload a single Terraform plan file
datadog-ci terraform upload plan ./terraform-plan.json
# Upload multiple Terraform plan files
datadog-ci terraform upload plan ./plan1.json ./plan2.json ./plan3.json
# Upload multiple plan files using glob expansion
datadog-ci terraform upload plan ./plans/*.json
# Upload a Terraform state file
datadog-ci terraform upload state ./terraform.tfstate
# Upload with manual repo-id override
datadog-ci terraform upload plan ./terraform-plan.json --repo-id "github.com/my-org/my-repo"
# Dry run mode
datadog-ci terraform upload plan ./terraform-plan.json --dry-run
# Upload multiple files with verbose logging
datadog-ci terraform upload plan ./plan1.json ./plan2.json --verboseThe Git context is resolved in the following order of priority:
- CI environment variables
- Current Git repository metadata
- Override environment variables (
DD_GIT_*variables)
The repository identifier (repo_id) is resolved in this order:
--repo-idflag valueDD_GIT_REPOSITORY_URLorDD_REPOSITORY_URLenvironment variable- Git metadata from the current repository
To test locally, run:
yarn launch terraform upload plan /path/to/terraform-plan.json- The command accepts one or more files per invocation. All files must be of the same artifact type (plan or state).
- Files are automatically gzipped before upload.
- The command computes a SHA256 hash of each file's content.
- No client-side validation or filtering of file content is performed (as per RFC requirements).
- Git metadata is synced only once per invocation, even when uploading multiple files.