Terraform Registry
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
Description
The terraform/registry resource queries a Terraform registry for the versions of a provider or a module. It is the read half of the Terraform workflow: this resource finds the version, and terraform/provider, terraform/lock or terraform/file write it into your configuration.
- source
Returns the version matching
versionfilter.- condition
Checks that
versionexists in the registry.- target
Not supported - a registry is read-only. A target fails with
Target not supported for the plugin terraform/registry.
Note | An scm attached to a condition is ignored; the lookup always goes to the registry over HTTP. |
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| hostname | string | “hostname” defines the hostname of the registry hosting the provider or module. compatible:
default: registry.terraform.io remark:
example:
| |
| name | string | “name” defines the name of the provider or module. compatible:
remark:
example:
| |
| namespace | string | “namespace” defines the namespace of the provider or module. compatible:
remark:
example:
| |
| rawstring | string | “rawstring” defines the provider or module reference in the registry as a single string. compatible:
remark:
example:
| |
| targetsystem | string | “targetsystem” defines the target system of the module in the registry. compatible:
remark:
example:
| |
| type | string | “type” defines the type of registry object to look up. compatible:
remark:
example:
| |
| version | string | “version” defines the version to check. compatible:
default: the output of the associated source. | |
| versionfilter | object | “versionfilter” defines the filter used to select the version, such as a regex, semver or latest pattern. compatible:
default: kind: semver pattern: “*” | |
| kind | string | “kind” defines the versioning scheme used to select a version. default: latest remark:
example:
| |
| pattern | string | “pattern” defines the version pattern, according to “kind”. default:
remark:
example:
| |
| regex | string | “regex” defines the regular expression extracting the version from each entry. remark:
example:
| |
| replaceall | object | “replaceall” applies a regular expression replacement to each version before filtering. remark:
example: turns “curl-8_15_0” into “curl-8.15.0”. | |
| strict | boolean | “strict” enforces strict semantic versioning rules when parsing versions. default: false remark:
|
type is mandatory and must be provider or module. The address of what to look up is then given in one of two mutually exclusive styles.
Addressing by rawstring
rawstring is the whole address in one string, in the form Terraform itself uses:
spec:
type: provider
rawstring: hashicorp/kubernetes # or registry.terraform.io/hashicorp/kubernetesspec:
type: module
rawstring: terraform-aws-modules/vpc/aws # or app.terraform.io/terraform-aws-modules/vpc/awsrawstring cannot be combined with hostname, namespace, name or targetsystem.
Addressing by components
| Field | Required | Notes |
|---|---|---|
| yes | The organisation publishing it, e.g. |
| yes | The provider or module name, e.g. |
| modules only | The target system, e.g. |
| no | Defaults to the public registry. Set it for a private one such as |
A module address must resolve to three or four slash-separated components. Getting it wrong is reported by the address parser rather than by a field-level message:
failed to create resource terraform/registry: a module registry source address must have either three or four slash-separated componentsVersion selection
versionfilter defaults to kind: semver with pattern * when it is not set - unlike most resources, which default to the generic filter. See the "Version Filtering" page.
version is condition-only: it names the version whose existence is being checked.
Example
# updatecli.yaml
name: Terraform Registry
sources:
kubernetes:
name: Get version from registry
kind: terraform/registry
spec:
type: provider
namespace: hashicorp
name: kubernetes
terraform-aws-modules:
name: Get version from registry
kind: terraform/registry
spec:
type: module
namespace: terraform-aws-modules
name: vpc
targetsystem: aws
conditions:
provider-using-value:
name: Condition using value
kind: terraform/registry
disablesourceinput: true
spec:
type: provider
namespace: hashicorp
name: kubernetes
version: 2.22.0
module-using-value:
name: Condition using value
kind: terraform/registry
disablesourceinput: true
spec:
type: module
namespace: terraform-aws-modules
name: vpc
targetsystem: aws
version: 5.1.0