This module runs the provided PEX binary in a portable manner that works with multiple platforms and python versions, to be used as an external data source in Terraform.
This module uses prepare-pex-environment
under the hood. See What is
PEX? for more details on what is a PEX file and how to construct one
for use with this module.
- See the pex example for example usage.
- See variables.tf for all the variables you can set on this module.
- See outputs.tf for all the variables that are outputed by this module.
Terraform provides two escape hatches where a first-class Terraform provider is not more appropriate. The escape hatches allow you to call out to arbitrary binaries available on the operator machine. These are:
- External Data Source, where you can run the binary as a data source.
- local-exec Provisioners, where you can run the binary to provision a resource.
This module uses the data source approach (you can see the run-pex-as-resource module for running it as a data source). Which approach to use depends on your needs:
- Data sources are calculated every time a terraform state needs to be refreshed. This includes all
plan
andapply
calls, even if the data source isn't explicitly changed. - Data sources are useful if the logic can be used to determine if a resource needs to be changed.
- Data sources can output values that can be used in other parts of the Terraform code. You cannot do this with the provisioner approach.
- There are limitations with Data Sources and dependencies. See this terraform issue comment for example.
- Provisioners with a
null_resource
implements the standard resource life cycle (create, destroy, etc). - Provisioners with a
null_resource
have explicit controls on when to trigger.