Terraform
Manage module versions API reference
This topic provides reference information about API endpoints that let your deprecate module versions in your organization’s private registry.
Introduction
When you deprecate a module version, HCP Terraform adds warnings to the module's registry page and to run outputs when anyone uses the deprecated version.
BEGIN: TFC:only name:pnp-callout
Note: Module deprecation is available in the HCP Terraform Plus Edition. Refer to HCP Terraform pricing for details.
END: TFC:only name:pnp-callout
After deprecating a module version, you can revert that deprecated status to remove the warnings from that version in the registry and outputs. For more details on module deprecation, refer to Deprecate module versions.
Note: The ability to deprecate module versions is in public beta. All APIs and workflows are subject to change.
Deprecate a module version
Use this endpoint to deprecate a module version.
PATCH /api/v2/organizations/:organization_name/registry-modules/private/:organization_name/:module_name/:module_provider/:module_version
Parameter | Description |
---|---|
:organization_name | The name of the organization the module belongs to. |
:module_name | The name of the module whose version you want to deprecate. |
:module_provider | Specifies the Terraform provider that this module is used for. |
:module_version | The module version you want to deprecate. |
This endpoint allows you to deprecate a specific module version. Deprecating a module version adds warnings to the run output of any consumers using this module.
Status | Response | Reason |
---|---|---|
200 | JSON API document | Successfully deprecated a module version. |
404 | JSON API error object | This organization is not authorized to deprecate this module version, or the module version does not exist. |
422 | JSON API error object | Malformed request body, for example the request is missing attributes or uses the wrong types. |
500 or 503 | JSON API error object | Failure occurred while deprecating a module version. |
Sample payload
{
"data": {
"type": "module-versions",
"attributes": {
"deprecation": {
"deprecated-status": "Deprecated",
"reason": "Deprecated due to a security vulnerability issue.",
"link": "https://www.hashicorp.com/"
}
}
}
}
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data @payload.json \
https://app.terraform.io/api/v2/organizations/hashicorp/registry-modules/private/hashicorp/lb-http/google/11.0.0
Sample response
{
"data": {
"type": "module-versions",
"id": "1",
"relationships": {
"deprecation": {
"data": {
"id": "2",
"type": "deprecations"
}
}
}
},
"included": [
{
"type": "deprecations",
"id": "2",
"attributes": {
"link": "https://www.hashicorp.com/",
"reason": "Deprecated due to a security vulnerability issue. Applies will be blocked in 15 days."
}
}
]
}
Revert the deprecation status for a module version
Use this endpoint to revert the deprecation of a module version.
PATCH /api/v2/organizations/:organization_name/registry-modules/private/:organization_name/:module_name/:module_provider/:module_version
Parameter | Description |
---|---|
:organization_name | The name of the organization the module belongs to. |
:module_name | The name of the module you want to revert the deprecation of. |
:module_provider | Specifies the Terraform provider that this module is used for. |
:module_version | The module version you want to revert the deprecation of. |
Deprecating a module version adds warnings to the run output of any consumers using this module. Reverting the deprecation status removes warnings from the output of consumers and fully reinstates the module version.
Status | Response | Reason |
---|---|---|
200 | JSON API document | Successfully reverted a module version’s deprecation status and reinstated that version. |
404 | JSON API error object | This organization is not authorized to revert the depreciation of this module version, or the module version does not exist. |
422 | JSON API error object | Malformed request body, for example the request is missing attributes or uses the wrong types. |
500 or 503 | JSON API error object | Failure occurred while reverting the deprecation of a module version. |
Sample request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data @payload.json \
https://app.terraform.io/api/v2/organizations/hashicorp/registry-modules/private/hashicorp/lb-http/google/11.0.0
Sample payload
{
"data": {
"type": "module-versions",
"attributes": {
"deprecation": {
"deprecated-status": "Undeprecated"
}
}
}
}
Sample response
{
"data": {
"type": "module-versions",
"id": "1"
}
}
Fetch a module version’s deprecation data
Send a GET
request to the /modules/:GitHub-organization/:module/:provider/versions
endpoint to retrieve data about private registry modules, including the module's deprecation status. Refer to the private registry module API example for additional information.
For example, if you want to know the deprecation status of v0.0.1 of the aws
provider’s consul
module in your my-cloud-org
organization, you could perform the following API call:
curl \
--header "Authorization: Bearer $TOKEN" \
https://app.terraform.io/api/registry/v1/modules/my-cloud-org/consul/aws/0.0.1
If the module is deprecated, your response includes a deprecation
key with the details of that module version’s deprecation.
{
"id": "hashicorp/consul/aws/0.0.1",
"owner": "gruntwork-team",
"namespace": "hashicorp",
"name": "consul",
"version": "0.0.1",
"provider": "aws",
"description": "A Terraform Module for how to run Consul on AWS using Terraform and Packer"
// ... //
"deprecation": {
"reason": "This version was deprecated due to a vulnerability issue. Please upgrade to 0.0.2.",
"link": "https://hashicorp.com"
}
}
To check the deprecation status of all of the consul
module’s versions, you could perform the following API call:
curl \
--header "Authorization: Bearer $TOKEN" \
https://app.terraform.io/api/registry/v1/modules/my-cloud-org/consul/aws/versions
The response includes multiple versions, and each version has a deprecation
key listing the details of that module’s deprecation. If a module version has not been deprecated, the deprecation
field returns null
.
{
"modules": [
{
"source": "hashicorp/consul/aws",
"versions": [
{
"version": "0.0.1",
// ... //
"deprecation": {
"reason": "security vulnerability",
"link": "www.hashicorp.com"
}
},
{
"version": "0.0.2",
"submodules": [],
"root": {
"dependencies": [],
"providers": [
{
"name": "template",
"version": ""
},
{
"name": "aws",
"version": ""
}
]
},
"deprecation": null
}
]
}
]
}