On this page
Terraform Lock
| source | condition | target |
|---|---|---|
✗ | ✔ | ✔ |
Description
The terraform/lock resource maintains a .terraform.lock.hcl dependency lock file: for a given provider it updates the version, the version constraint, and the package checksums - without running terraform init. The checksums are fetched from the registry for the platforms you list.
- condition
Tests that the lock file already records that version and its hashes for the provider.
- target
Rewrites the provider’s
version,constraintsandhashesentries.- source
Not supported - a source fails with
Source not supported for the plugin terraform/lock. Pair this resource withterraform/registry, which supplies the version.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| file | string | “file” defines the path of the Terraform lock file to use. compatible:
remark:
| |
| files | array | “files” defines the list of Terraform lock file paths to use. compatible:
remark:
| |
| platforms | array | “platforms” defines the target platforms to request package checksums for. compatible:
remark:
example:
| |
| provider | string | “provider” defines the Terraform provider to update. compatible:
remark:
example:
| |
| skipconstraints | boolean | “skipconstraints” defines whether the constraints of the lock file are left untouched. compatible:
default: false remark:
| |
| value | string | “value” defines the version of the Terraform provider. compatible:
default: in a condition or a target, the output of the associated source. |
file or files, provider and platforms are all mandatory - missing any of them aborts the run with wrong spec content, preceded by terraform/lock file undefined, terraform/lock provider undefined or terraform/lock platforms undefined. file and files are mutually exclusive, and a condition accepts only one file.
providerAccepts the short form or the fully qualified one (
hashicorp/kubernetesandregistry.terraform.io/hashicorp/kubernetesboth work).platformsThe platforms to request checksums for, such as
linux_amd64ordarwin_arm64. Only the platforms listed here end up in the lock file, exactly as withterraform providers lock -platform=…. Omitting the platform your CI runs on will maketerraform initfail there.
Warning |
|
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 Lock
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/lock
disablesourceinput: true
spec:
file: .terraform.lock.hcl
provider: hashicorp/kubernetes
platforms:
- linux_amd64
value: 2.22.0
https:
name: Condition using HTTP
kind: terraform/lock
disablesourceinput: true
spec:
file: https://raw.githubusercontent.com/updatecli-test/jenkins-infra-aws/main/.terraform.lock.hcl
provider: hashicorp/kubernetes
platforms:
- linux_amd64
value: 2.22.0
targets:
update-file-from-source:
name: Update files content from value
kind: terraform/lock
sourceid: kubernetes
spec:
file: .terraform.lock.hcl
provider: hashicorp/kubernetes
platforms:
- linux_amd64
Links
The
terraform/providerresource - for therequired_providersblock