data.tf `����U p�0��U variable "foo" { type = "string" default = "baz" } data "external" "example" { program = ["bash", "test.sh"] query = { foo = "${var.foo}" } } output "example" { value = "${data.external.example.result["bar"]}" } memo.md query に指定した値を json として コマンドに渡している 外部コマンドは json を出力する 値の参照は data.external.example.result["bar"] のように、 .result[KEY] で $ echo '{"foo":"baz"}' | bash test.sh { "b
![terraform の external data source を使って外部コマンドの実行結果を variable として使用する](https://cdn-ak-scissors.b.st-hatena.com/image/square/1ef26f6cb4349557952890dbe3e567f7f98dc151/height=288;version=1;width=512/https%3A%2F%2Fgithub.githubassets.com%2Fassets%2Fgist-og-image-54fd7dc0713e.png)