Terraform Module Registry API

This is the API documentation for the Terraform Module Registry.

caution
This API is used by the Terraform CLI and is generally not meant for manual consumption. Undocumented authentication methods might be removed in the future.

For instructions on how to upload and install Terraform modules from the GitLab Terraform Module Registry, see the Terraform Module Registry documentation.

List available versions for a specific module

Get a list of available versions for a specific module.

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/versions
AttributeTypeRequiredDescription
module_namespacestringyesThe top-level group (namespace) to which Terraform module’s project or subgroup belongs.
module_namestringyesThe module name.
module_systemstringyesThe name of the module system or provider.
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"

Example response:

{
  "modules": [
    {
      "versions": [
        {
          "version": "1.0.0",
          "submodules": [],
          "root": {
            "dependencies": [],
            "providers": [
              {
                "name": "local",
                "version":""
              }
            ]
          }
        },
        {
          "version": "0.9.3",
          "submodules": [],
          "root": {
            "dependencies": [],
            "providers": [
              {
                "name": "local",
                "version":""
              }
            ]
          }
        }
      ],
      "source": "https://gitlab.example.com/group/hello-world"
    }
  ]
}

Latest version for a specific module

Get information about the latest version for a given module.

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system
AttributeTypeRequiredDescription
module_namespacestringyesThe group to which Terraform module’s project belongs.
module_namestringyesThe module name.
module_systemstringyesThe name of the module system or provider.
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local"

Example response:

{
  "name": "hello-world/local",
  "provider": "local",
  "providers": [
    "local"
  ],
  "root": {
    "dependencies": []
  },
  "source": "https://gitlab.example.com/group/hello-world",
  "submodules": [],
  "version": "1.0.0",
  "versions": [
    "1.0.0"
  ]
}

Get specific version for a specific module

Get information about a specific version for a given module.

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/1.0.0
AttributeTypeRequiredDescription
module_namespacestringyesThe group to which Terraform module’s project belongs.
module_namestringyesThe module name.
module_systemstringyesThe name of the module system or provider.
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0"

Example response:

{
  "name": "hello-world/local",
  "provider": "local",
  "providers": [
    "local"
  ],
  "root": {
    "dependencies": []
  },
  "source": "https://gitlab.example.com/group/hello-world",
  "submodules": [],
  "version": "1.0.0",
  "versions": [
    "1.0.0"
  ]
}

Get URL for downloading latest module version

Get the download URL for latest module version in X-Terraform-Get header

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/download
AttributeTypeRequiredDescription
module_namespacestringyesThe group to which Terraform module’s project belongs.
module_namestringyesThe module name.
module_systemstringyesThe name of the module system or provider.
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/download"

Example response:

HTTP/1.1 204 No Content
Content-Length: 0
X-Terraform-Get: /api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/file?token=&archive=tgz

Under the hood, this API endpoint redirects to packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version/download

Get URL for downloading specific module version

Get the download URL for a specific module version in X-Terraform-Get header

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version/download
AttributeTypeRequiredDescription
module_namespacestringyesThe group to which Terraform module’s project belongs.
module_namestringyesThe module name.
module_systemstringyesThe name of the module system or provider.
module_versionstringyesSpecific module version to download.
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/download"

Example response:

HTTP/1.1 204 No Content
Content-Length: 0
X-Terraform-Get: /api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/file?token=&archive=tgz

Download module

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version/file
AttributeTypeRequiredDescription
module_namespacestringyesThe group to which Terraform module’s project belongs.
module_namestringyesThe module name.
module_systemstringyesThe name of the module system or provider.
module_versionstringyesSpecific module version to download.
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/file"

To write the output to file:

curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/file" --output hello-world-local.tgz