Created
June 6, 2026 13:47
-
-
Save maxsei/99c4ee04f5f68e55e3d977adfba1253f to your computer and use it in GitHub Desktop.
how to use data external scripts in terraform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log( | |
| JSON.stringify({ | |
| result: "hello world", | |
| json: JSON.stringify({ | |
| hello: "world", | |
| }), | |
| }), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data "external" "hello_world" { | |
| program = ["node", "main.js"] | |
| } | |
| output "result" { | |
| value = data.external.hello_world.result["result"] | |
| } | |
| output "json" { | |
| value = jsondecode(data.external.hello_world.result["json"]) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ tofu apply | |
| data.external.hello_world: Reading... | |
| data.external.hello_world: Read complete after 0s [id=-] | |
| No changes. Your infrastructure matches the configuration. | |
| OpenTofu has compared your real infrastructure against your configuration and found no differences, so no changes are needed. | |
| Apply complete! Resources: 0 added, 0 changed, 0 destroyed. | |
| Outputs: | |
| json = { | |
| "hello" = "world" | |
| } | |
| result = "hello world" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment