Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Run PEX as Data Source

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.

How do you use this module?

  • See the pex example for example usage.
  • See for all the variables you can set on this module.
  • See for all the variables that are outputed by this module.

Data Source vs Resource

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:

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 and apply 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.
You can’t perform that action at this time.