Terraform Registry

JFrog Artifactory Documentation

ft:sourceType
Paligo
Overview

The Terraform registry in Artifactory allows you to create dedicated repositories for each of the following unique Terraform components:

  • Providers: A set of plugins that interact with cloud providers, SaaS providers, and other APIs.

  • Modules: Serve as containers for multiple resources that are used together. Modules contain a collection of .tf files kept together in a directory.

The Modules and Providers have different settings for local repositories but are the same when it comes to configuring remote and virtual repositories.

To learn more about the Terraform repository solution in the JFrog Platform, see Terraform Repositories.

Terraform Module Registry

Terraform Modules are Terraform configurations that can be called and configured by other configurations. They serve as containers for multiple resources that are used together. They contain a collection of.tf files kept together in a directory. To create a module, pack all your .tf files into a Zip archive and deploy to the Terraform local repository. For more information, see Creating Terraform Modules.

Terraform Module Repository Structure

The Terraform Module repository is a directory with a collection of Zip files, consisting of these main coordinates:

  • namespace

  • module

  • Provider

  • version.zip

Artifactory complies with the Terraform Module directory layout convention.

namespace/module-name/provider/version.zip

For example:

terraform-aws-modules/vpc/aws/2.0.0.zip
harshicorp/consul/aws/DEV-123.zip
Terraform Provider Registry

Providers are a set of plugins that interact with cloud providers, SaaS providers and other APIs.

Terraform Provider Repository Structure

The Terraform Provider repository is a directory with a collection of Zip files consisting of these main coordinates:

  • Namespace

  • Provider

  • Version.zip

  • Operating system

  • Architecture

Artifactory complies with the Terraform Provider directory layout convention.

namespace/provider/version/terraform-provider-{NAME}_{VERSION}_{OS}_{ARCH}.zip

For example:

/google/3.88.0/terraform-provider-google_3.88.0_darwin_amd64.zip
Setting up a Terraform Module/Provider Registry

You can set up the following repository types:

Setting up a Local Module/Provider Registry

Local repositories enable you to deploy the Terraform Module or Provider as a zip archive. Artifactory calculates the metadata for all packages and indexes them to allow users to download these packages through the Terraform CLI.

  1. To create a Terraform Module/Provider local repository, navigate to the Administration module.

  2. Navigate to Repositories | Repositories | Local | New Local Repository and select Terraform as the Package Type.

  3. In the Basic tab, from the Terraform Registry Type list:

    • Select Module to apply the terraform-module-default repository layout.

    • Select Provider to apply the terraform-provider-default repository layout.

terraform_local_module_provider.png
Setting up a Remote Terraform Registry

Remote Repositories enable you to proxy and cache your remote Terraform Modules and Providers packages.

To specify that a Remote Repository supports Terraform packages, you will need to set its Package Type to Terraform when it is created.

Note that the Remote repository settings are identical for both Providers and Modules.

new_remote_repository.png

Follow these guidelines regarding the specific Terraform settings.

Field

Description

URL

The base URL of the Module storage API.

When using Smart remote repositories, set the URL to <base_Artifactory_URL>/repokey.

Git Providers

It is recommended to select Github when pointing to the official HashiCorp Terraform Registry.

Note that other Git Providers are not supported.

Registry URL

The base URL of the registry API.

When using Smart Remote Repositories, set the URL to <base_Artifactory_URL>/api/terraform/repokey

Providers URL

The base URL of the Provider's storage API.

When using Smart remote repositories, set the URL to <base_Artifactory_URL>/api/terraform/repokey/providers

For information on the common Remote repository fields, see Remote Repositories.

Note

Starting from version 7.39.4, The default Terraform behavior is to override the source URL when initializing a module. It is not recommended to disable this feature, but if you need to, you can do so by setting this system property:

artifactory.terraform.override.modules.source.hostname=false
Setting up a Virtual Terraform Registry

A Virtual Repository defined in Artifactory aggregates packages from both local and remote repositories.

This allows you to access both locally hosted Modules and Providers and remote proxied Terraform repositories from a single URL defined for the Virtual Repository.

To define a virtual Terraform repository, do the following:

  1. Create a Virtual Repositories, and set the Package Type to be Terraform.

  2. Select the underlying local and remote Terraform Module or Provider repositories to include in the Basic settings tab.

Resolving Terraform Module/Provide Packages
Generating an Access Token

To use Artifactory with your Terraform CLI, you will need to generate an access token using the following two methods:

Generating an Access Token Using Browser Login
  1. Natively run the Terraform login to your Artifactory domain to generate an access token and save it in the Credentials file ( ~/.terraform.d/credentials.tfrc.json.). When you run the login, the following page opens.

    Terraform_setmeup_CLI.png

    The Terraform command line login process is displayed.