Using External Data and Templates
Pull dynamic values into Terraform with the external data source and render configuration files using the templatefile function.
Beyond Built-in Data Sources
You already query AWS with data sources. Sometimes the data you need lives outside any provider, like the output of a shell script or an internal API. The external data source and template functions fill this gap.
The external Data Source
The external data source runs a program and reads JSON from its stdout. It is an escape hatch for logic Terraform cannot express natively.
data "external" "git_sha" {
program = ["bash", "./scripts/git_sha.sh"]
}All lessons in this course
- Querying Data with Data Sources
- Local and Remote Exec Provisioners
- Null Resources and Triggers
- Using External Data and Templates