Skip to content

Instantly share code, notes, and snippets.

@infamousjoeg
Created May 15, 2024 14:48
Show Gist options
  • Save infamousjoeg/dabe06c3ea0110d483e73f33aa8ac32e to your computer and use it in GitHub Desktop.
Save infamousjoeg/dabe06c3ea0110d483e73f33aa8ac32e to your computer and use it in GitHub Desktop.
How to use a custom Terraform provider that was built from source

To use a custom version of the cyberark/conjur provider in Terraform, you would follow a similar procedure to what was previously described but tailored specifically for this provider. Here are the detailed steps to set up the cyberark/conjur provider that has been compiled from source:

  1. Compile the Provider: Start by ensuring you have the source code for the CyberArk Conjur provider. You can typically find this on GitHub under the CyberArk organization. After obtaining the code, compile it using Go. Navigate to the directory containing the provider's source code and run:

    go build
    

    This command compiles the provider into an executable binary.

  2. Create the Directory Structure: You need to place the compiled provider binary in a specific directory structure that Terraform recognizes. The path should be structured as follows:

    terraform.d/plugins/registry.terraform.io/cyberark/conjur/X.Y.Z/<OS_ARCH>
    

    Replace X.Y.Z with the version number you are using, and <OS_ARCH> with your operating system and architecture, such as linux_amd64 or darwin_amd64. For example:

    terraform.d/plugins/registry.terraform.io/cyberark/conjur/0.6.7/darwin_arm64/
    
  3. Copy the Provider Plugin: Place the compiled provider binary into the directory you created. Ensure the binary's name is correctly formatted to be recognized by Terraform. It should be:

    terraform-provider-conjur_vX.Y.Z
    

    Adjust X.Y.Z to match the version number you used in the directory path.

  4. Configure Terraform to Use the Local Provider: In your Terraform configuration file, specify that Terraform should use the local version of the CyberArk Conjur provider. Include a required_providers block in your terraform settings like this:

    terraform {
      required_providers {
        conjur = {
          source  = "cyberark/conjur"
          version = "0.6.7"
        }
      }
    }

    Here, replace 1.2.3 with the actual version number of your custom provider.

  5. Initialize Terraform: Run terraform init in the directory where your configuration file is located. Terraform will check the directory structure you created for the appropriate provider plugin. If it finds the plugin, it will use this version instead of downloading it from the Terraform Registry.

This setup ensures that Terraform uses your locally compiled version of the CyberArk Conjur provider. Double-check the paths and naming to avoid any issues during Terraform's initialization process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment