Introduction
Terraform CLI version 0.13 and later offers methods for provider installation in addition to the default provider registry. In order to override the default provider installation method, a provider_installation
block must be set in the Terraform configuration file.
In Terraform Enterprise, the configuration file is dynamically generated for each run and contains internal information required by Terraform Enterprise. Since the configuration file is managed internally and dynamically, it is not possible to edit the configuration file to add the provider_installation
block directly. This article provides the steps to configure the provider_installation
block in Terraform Enterprise.
Use Case
This article is applicable to Terraform Enterprise users who require non-default provider installation methods.
Procedure
-
In order to add
provider_installation
into the generated Terraform configuration file, a custom worker image is required. The most important consideration when creating a custom worker image is ensuring it meets the defined requirements. As long as the requirements are met, additional tools or scripts may be added as needed. -
Create an initialization script for the custom worker image which contains the logic to append the required
provider_installation
block into the generated Terraform configuration file (located at/tmp/cli.tfrc
). The example below is the script for configuring the network mirror installation method.# /usr/local/bin/init_custom_worker.sh #!/bin/bash cat >> /tmp/cli.tfrc <<EOF provider_installation { network_mirror { url = "https://providers.tfe-example.com/artifactory/terraform-providers/" } } EOF
-
Add the initialize script created in the previous step to the custom worker image. Please note that there are strict requirements and notes around the file path and permissions of the script.
-
Make sure that Terraform Enterprise is configured to use the custom worker image by opening the installer dashboard at port 8800 of the installation and choosing Settings > Terraform Build Worker Image > Provide the location of a custom image. Please note that an application restart is required for the custom worker image configuration to take effect.
Additional information
Please visit the provider installation page for further information of the Terraform configuration file.