Python script to read from SaltStack Pillar, and return the value in Terraform as external data source.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Terraform external data source script for SaltStack Pillar.


SaltStack is more than configuration management tool, and in some environment it's Pillar has a lot of data which could be needed somewhere else, e.g. Terraform!

So this Python script works as external data source and reads from SaltStack Pillar, and returns the value in Terraform as external data source.

How to use

You can query any Pillar key from SaltStack and get the value in Terraform:

data "external" "pillar" {
  program = ["python", "${path.module}/"]
  query = {
    pillar = "foo:bar"

A full example available in

Access and limitations

Actually it's not necessary to just have a single key, but also if that key has other keys under it you still can access them too, as long as they are strings!

So for example, if the Pillar has the following:

    key01: "value01"
    key02: "value02"
    key03: "value03"

And based on previous external data source example if you query foo:bar, you can also access the keys under it: