Example external Terraform data object to fetch data from an API
Name | Version |
---|---|
terraform | ~> 1.2 |
python | ~> 3.10 |
curl | ~ |
jq | ~ |
- Modify versions.tf with your own state information. Local or otherwise
- Ideally you would want to set up a virtual environment
python -m venv /path/to/virtual/environment
- Install requirements
python -m pip install -r requirements.txt
Init state
terraform init
Plan
terraform plan
Apply
terraform apply
Name | Description |
---|---|
message | The message value from the JSON object |
html_url | The URL of the repo |
In practice python isn't the best choice for an external datasource as it will likely have dependencies best satisfied in a virtualenv making it less portable. I'd recommend a simple shell script or a checked in static binary.