0Pricing
Terraform Infrastructure as Code · Lesson

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

  1. Querying Data with Data Sources
  2. Local and Remote Exec Provisioners
  3. Null Resources and Triggers
  4. Using External Data and Templates
← Back to Terraform Infrastructure as Code