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 hcl file path to interact with.

compatible: * source * condition * target

remark: * “file” and “files” are mutually exclusive * protocols “https://”, “http://”, and “file://” are supported in path for source and condition

filesarray

“files” defines the list of hcl files path to interact with.

compatible: * source * condition * target

remark: * file and files are mutually exclusive * when using as a source only one file is supported * protocols “https://”, “http://”, and “file://” are supported in file path for source and condition

pathstring

“path” defines the hcl attribute path.

compatible: * source * condition * target

example: * path: resource.aws_instance.app_server.ami * path: resource.helm_release.prometheus.version * path: plugin.aws.version

valuestring

“value” is the value associated with a hcl path.

compatible: * condition * target

default: When used from a condition or a target, the default value is set to linked source output.

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