This tool validates and processes metadata JSON files for use in infrastructure pipelines such as Terraform. It can be run locally, inside Docker, or within Bitbucket Pipelines.
export METADATA="$(cat <metadata_path> | jq -c)"
export PAGERDUTY_TOKEN=<your_pagerduty_token>
export ENVIRONMENT=<production|stage>Replace
<metadata_path>with the full path to yourmetadata.json.
ENVIRONMENTonly acceptsproductionorstage.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtpython app/pipe.pydocker build -t metadata-pipe --no-cache .
docker run --rm \
-e PAGERDUTY_TOKEN="${PAGERDUTY_TOKEN}" \
-e METADATA="${METADATA}" \
-e ENVIRONMENT="${ENVIRONMENT}" \
metadata-pipeimage: python:3.10
pipelines:
default:
- step:
name: Validate Metadata
script:
- pip install -r requirements.txt
- python pipe.pySet these in Repository Settings → Repository Variables:
| Variable Name | Description |
|---|---|
METADATA |
JSON string output from jq -c < metadata.json |
PAGERDUTY_TOKEN |
Your PagerDuty API token |
ENVIRONMENT |
Either production or stage |
- Shows validation results and environment checks.
- If invalid, prints an error and exits.
- If valid, prints:
Successfully Validated!
{
"service_name": "app-user-service",
"team": "backend",
"description": "User service for account registration and profile",
"alerting": {
"pagerduty": "abc123"
}
}