Terraform Module Registry API
DETAILS: Tier: Free, Premium, Ultimate Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
This is the API documentation for the Terraform Module Registry.
WARNING: 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
Attribute | Type | Required | Description |
---|---|---|---|
module_namespace |
string | yes | The top-level group (namespace) to which Terraform module's project or subgroup belongs. |
module_name |
string | yes | The module name. |
module_system |
string | yes | The 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
Attribute | Type | Required | Description |
---|---|---|---|
module_namespace |
string | yes | The group to which Terraform module's project belongs. |
module_name |
string | yes | The module name. |
module_system |
string | yes | The 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
Attribute | Type | Required | Description |
---|---|---|---|
module_namespace |
string | yes | The group to which Terraform module's project belongs. |
module_name |
string | yes | The module name. |
module_system |
string | yes | The 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
Attribute | Type | Required | Description |
---|---|---|---|
module_namespace |
string | yes | The group to which Terraform module's project belongs. |
module_name |
string | yes | The module name. |
module_system |
string | yes | The 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"
```0
Example response:
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```1
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
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```2
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `module_namespace` | string | yes | The group to which Terraform module's project belongs. |
| `module_name` | string | yes | The module name. |
| `module_system` | string | yes | The name of the module system or [provider](https://www.terraform.io/registry/providers). |
| `module_version` | string | yes | Specific module version to download. |
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```3
Example response:
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```4
## Download module
### From a namespace
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```5
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `module_namespace` | string | yes | The group to which Terraform module's project belongs. |
| `module_name` | string | yes | The module name. |
| `module_system` | string | yes | The name of the module system or [provider](https://www.terraform.io/registry/providers). |
| `module_version` | string | yes | Specific module version to download. |
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```6
To write the output to file:
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```7
### From a project
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```8
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID or URL-encoded path of the project. |
| `module_name` | string | yes | The module name. |
| `module_system` | string | yes | The name of the module system or [provider](https://www.terraform.io/registry/providers). |
| `module_version` | string | no | Specific module version to download. If omitted, the latest version is downloaded. |
```shell
curl --header "Authorization: Bearer <personal_access_token>" "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"
```9
To write the output to file:
```json
{
"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"
}
]
}
```0
## Upload module
```json
{
"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"
}
]
}
```1
| Attribute | Type | Required | Description |
|------------------|-------------------|----------|-------------|
| `id` | integer or string | yes | The ID or URL-encoded path of the project. |
| `module-name` | string | yes | The module name. |
| `module-system` | string | yes | The name of the module system or [provider](https://www.terraform.io/registry/providers). |
| `module-version` | string | yes | Specific module version to upload. |
```json
{
"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"
}
]
}
```2
Tokens that can be used to authenticate:
| Header | Value |
|-----------------|-------|
| `PRIVATE-TOKEN` | A [personal access token](../../user/profile/personal_access_tokens.md) with `api` scope. |
| `DEPLOY-TOKEN` | A [deploy token](../../user/project/deploy_tokens/index.md) with `write_package_registry` scope. |
| `JOB-TOKEN` | A [job token](../../ci/jobs/ci_job_token.md). |
Example response:
```json
{
"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"
}
]
}
```3