Querying external data with Terraform
In the previous recipe, we learned that it is possible to use the data
to retrieve external data. However, there are scenarios where the data block does not exist in the provider, such as when we need to process with an external API or need to use a local tool and process its output.
To meet this need, there is an external
resource in Terraform that allows you to call an external program and retrieve its output data so that it can be used in the Terraform configuration.
Use of the
external
provider imposes prerequisites that may not be obvious (for example, in this case, we expect a particular version of PowerShell) or may be difficult to communicate other than throughREADME
files or documentation. Also, Terraform is generally designed to work the same cross-platform (operating system/architecture), but this essentially restricts the configuration to platforms that can (and do) run PowerShell – presumably just Windows. These requirements...