正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。

Terraformモジュールレジストリ

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated

このAPIを使用して、Terraform CLIを操作します。

このAPIはTerraform CLIによって使用され、通常は手動での使用を意図していません。記載されていない認証方法は、将来削除される可能性があります。

特定のモジュールで利用可能なバージョンを一覧表示

特定のモジュールで利用可能なバージョンのリストを取得します。

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/versions
属性必須説明
module_namespace文字列はいTerraformモジュールのプロジェクトまたはサブグループが属するトップレベルグループ (ネームスペース)。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
curl --header "Authorization: Bearer <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/versions"

レスポンス例:

{
  "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"
    }
  ]
}

特定のモジュールの最新バージョン

特定のモジュールの最新バージョンに関する情報を取得します。

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system
属性必須説明
module_namespace文字列はいTerraformモジュールのプロジェクトが属するグループ。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
curl --header "Authorization: Bearer <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local"

レスポンス例:

{
  "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 packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/1.0.0
属性必須説明
module_namespace文字列はいTerraformモジュールのプロジェクトが属するグループ。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
curl --header "Authorization: Bearer <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0"

レスポンス例:

{
  "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"
  ]
}

最新のモジュールのバージョンをダウンロードするためのURLを取得

X-Terraform-Getヘッダーで、最新のモジュールのバージョンをダウンロードするためのURLを取得します

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/download
属性必須説明
module_namespace文字列はいTerraformモジュールのプロジェクトが属するグループ。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
curl --header "Authorization: Bearer <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/download"

レスポンス例:

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

内部的には、このAPIエンドポイントはpackages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version/downloadにリダイレクトされます

特定のモジュールのバージョンをダウンロードするためのURLを取得

X-Terraform-Getヘッダーで、特定のモジュールのバージョンをダウンロードするためのURLを取得します

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version/download
属性必須説明
module_namespace文字列はいTerraformモジュールのプロジェクトが属するグループ。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
module_version文字列はいダウンロードする特定のモジュールのバージョン。
curl --header "Authorization: Bearer <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/download"

レスポンス例:

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

モジュールをダウンロード

ネームスペースから

GET packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version/file
属性必須説明
module_namespace文字列はいTerraformモジュールのプロジェクトが属するグループ。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
module_version文字列はいダウンロードする特定のモジュールのバージョン。
curl --header "Authorization: Bearer <personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/packages/terraform/modules/v1/group/hello-world/local/1.0.0/file"

ファイルを出力に書き込むには:

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

プロジェクトから

GET /projects/:id/packages/terraform/modules/:module_name/:module_system/:module_version
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
module_name文字列はいモジュール名。
module_system文字列はいモジュールシステムまたはプロバイダーの名前。
module_version文字列いいえダウンロードする特定のモジュールのバージョン。省略した場合、最新バージョンがダウンロードされます。
curl --user "<username>:<personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/packages/terraform/modules/hello-world/local/1.0.0"

ファイルを出力に書き込むには:

curl --user "<username>:<personal_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/1/packages/terraform/modules/hello-world/local/1.0.0" \
  --output hello-world-local.tgz

モジュールをアップロード

PUT /projects/:id/packages/terraform/modules/:module-name/:module-system/:module-version/file
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
module-name文字列はいモジュール名。
module-system文字列はいモジュールシステムまたはプロバイダーの名前。
module-version文字列はいアップロードする特定のモジュールのバージョン。
curl --fail-with-body \
   --header "PRIVATE-TOKEN: <your_access_token>" \
   --upload-file path/to/file.tgz \
   --url  "https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/terraform/modules/my-module/my-system/0.0.1/file"

認証に使用できるトークン:

ヘッダー
PRIVATE-TOKENapiスコープを持つパーソナルアクセストークン
DEPLOY-TOKENwrite_package_registryスコープを持つデプロイトークン
JOB-TOKENジョブトークン

レスポンス例:

{
  "message": "201 Created"
}