sourceconditiontarget

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 version exists 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

NameTypeDescriptionRequired
hostnamestring

“hostname” the hostname of the provider or module.

compatible: * source * condition

remark: * Optional * Not allowed with rawstring. * Applicable for module and provider.

namestring

“name” the name of the provider or module.

compatible: * source * condition

remark: * Required unless using rawstring * Not allowed with rawstring. * Applicable for module and provider.

namespacestring

“namespace” the namespace of the provider or module

compatible: * source * condition

remark: * Required unless using rawstring * Not allowed with rawstring. * Applicable for module and provider.

rawstringstring

“rawstring” provider reference to registry in single string.

compatible: * source * condition

Examples: * hashicorp/kubernetes * registry.terraform.io/hashicorp/kubernetes * terraform-aws-modules/vpc/aws * app.terraform.io/terraform-aws-modules/vpc/aws

remark: * Applicable for module and provider. * Not allowed with hostname, namespace, name, and targetsystem.

targetsystemstring

“targetsystem” the target system for the module in registry

compatible: * source * condition

remark: * Required for type module unless using rawstring * Not allowed with rawstring * Applicable for module.

typestring

“type” defines the type registry request to look up.

compatible: * source * condition

Supported values: module, provider

versionstring

“version” defines a specific version to be used during condition check.

compatible: * condition

versionfilterobject

“versionfilter” provides parameters to specify version pattern and its type like regex, semver, or just latest.

compatible: * source

    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format
    regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
    replaceallobjectreplaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction.
    strictbooleanstrict enforce strict versioning rule. Only used for semantic versioning at this time

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/kubernetes
spec:
  type: module
  rawstring: terraform-aws-modules/vpc/aws                 # or app.terraform.io/terraform-aws-modules/vpc/aws

rawstring cannot be combined with hostname, namespace, name or targetsystem.

Addressing by components

FieldRequiredNotes

namespace

yes

The organisation publishing it, e.g. hashicorp.

name

yes

The provider or module name, e.g. kubernetes.

targetsystem

modules only

The target system, e.g. aws. Providers must not set it.

hostname

no

Defaults to the public registry. Set it for a private one such as app.terraform.io.

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 components

Version 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