On this page
Terraform Provider
| source | condition | target |
|---|---|---|
✗ | ✔ | ✔ |
Description
The terraform/provider resource updates the version of one provider inside a required_providers block, so you name the provider rather than working out its attribute path:
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.23.0"
}
}
}- condition
Tests that the block records the expected version for the provider.
- target
Updates that version.
- source
Not supported - a source fails with
Source not supported for the plugin terraform/provider. Get the version fromterraform/registry.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| file | string | “file” defines the file path to interact with. compatible: * condition * target remark: * “file” and “files” are mutually exclusive * protocols “https://”, “http://”, and “file://” are supported in path for condition | |
| files | array | “files” defines the list of files path to interact with. compatible: * condition * target remark: * file and files are mutually exclusive * when using as a condition only one file is supported * protocols “https://”, “http://”, and “file://” are supported in file path for condition | |
| provider | string | “provider” is the terraform provider you wish to update. compatible: * condition * target | |
| value | string | “value” is the value associated with a terraform provider. compatible: * condition * target default: When used from a condition or a target, the default value is set to linked source output. |
file or files and provider are mandatory; missing either aborts the run with wrong spec content, preceded by terraform/provider file undefined or terraform/provider provider undefined. file and files are mutually exclusive, and a condition accepts only one file.
providerThe key inside
required_providers-kubernetesin the example above, nothashicorp/kubernetes. Unliketerraform/lock, this resource matches on the block key rather than the registry address.valueDefaults to the source output.
Tip | Updating a provider usually means touching two files. Pair this resource with a terraform/lock target in the same pipeline so required_providers and .terraform.lock.hcl stay consistent. |
For any attribute that is not a provider version, use terraform/file, which addresses attributes by path.
Remote files
For a condition, file accepts https://, http:// and file://. A target must write locally and refuses a URL.
Example
The example uses an additional resource plugin: terraform/registry.
# updatecli.yaml
name: Terraform Provider
sources:
kubernetes:
name: Get version from registry
kind: terraform/registry
spec:
type: provider
namespace: hashicorp
name: kubernetes
conditions:
using-value:
name: Condition using value
kind: terraform/provider
disablesourceinput: true
spec:
file: versions.tf
provider: kubernetes
value: 2.22.0
targets:
update-file-from-source:
name: Update files content from value
kind: terraform/provider
sourceid: kubernetes
spec:
file: versions.tf
provider: kubernetes