sourceconditiontarget

✔

✔

✔

Description

terraform/file is an alias for hcl - the same spec, backed by the same implementation. Use whichever name reads better in your manifest; there is no behavioural difference.

source

Retrieves an attribute from a Terraform file at the configured path. A source accepts only one file.

condition

Tests that the attribute at that path matches the value.

target

Ensures the attribute is set to a specific value, editing in place so comments and formatting survive.

Parameters

NameTypeDescriptionRequired
filestring

“file” defines the path of the hcl file to use.

compatible:

  • source
  • condition
  • target

remark:

  • “file” and “files” are mutually exclusive.
  • the schemes “https://”, “http://” and “file://” are supported in a source or a condition.

example:

  • file: main.tf
filesarray

“files” defines the list of hcl file paths to use.

compatible:

  • source
  • condition
  • target

remark:

  • “file” and “files” are mutually exclusive.
  • in a source or a condition, “files” accepts only one entry.
  • the schemes “https://”, “http://” and “file://” are supported in a source or a condition.
pathstring

“path” defines the hcl attribute path.

compatible:

  • source
  • condition
  • target

remark:

  • “path” is required.

example:

  • path: resource.aws_instance.app_server.ami
  • path: resource.helm_release.prometheus.version
  • path: plugin.aws.version
valuestring

“value” defines the value associated with the hcl path.

compatible:

  • condition
  • target

default: the output of the associated source.

file or files is mandatory, as is path; missing either aborts the run with wrong spec content. file and files are mutually exclusive.

path walks the block labels joined with dots, so

resource "aws_instance" "app_server" {
  ami = "ami-830c94e3"
}

is addressed as resource.aws_instance.app_server.ami. It points at an attribute, never at a block.

Tip
To bump a provider version, reach for terraform/provider instead (it understands required_providers blocks directly, rather than needing the exact attribute path).

Remote files

For a source and a condition, file accepts https://, http:// and file://. A target refuses a URL with URL scheme is not supported for HCL target.

Example

The example uses an additional resource plugin: terraform/registry.

# updatecli.yaml
name: Terraform File

sources:
  terraform-aws-modules-eks:
    name: Get version from registry
    kind: terraform/registry
    spec:
      type: module
      namespace: terraform-aws-modules
      name: eks
      targetsystem: aws

conditions:
  using-value:
    name: Condition using value
    kind: terraform/file
    scmid: default
    disablesourceinput: true
    spec:
      file: cik8s-cluster.tf
      path: module.cik8s.source
      value: terraform-aws-modules/eks/aws

targets:
  update-file:
    name: Update files content
    kind: terraform/file
    sourceid: terraform-aws-modules-eks
    scmid: default
    spec:
      file: cik8s-cluster.tf
      path: module.cik8s.version