Config Commands

The stategraph config command group manages the client-side stategraph.json file in your module directory. It edits the file locally and does not contact the server.

Why attach files

When your HCL reads external files — via file(), templatefile(), fileset(), filebase64(), or data.local_file — Stategraph needs to know which files belong to a change. stategraph config files records these as globs in stategraph.json, keyed by workspace and an address glob. When any attached file changes, the matching resources are included in the next plan.

Commands

Command Description
stategraph config files attach Attach file globs to an address glob under a workspace
stategraph config files remove Remove file globs, or an entire address entry

stategraph config files attach

Attach file globs to an address glob under a workspace. Takes the union with any globs already attached at that address.

stategraph config files attach --workspace <workspace> --address <address-glob> <file-glob>...

Options

Option Required Description
--address Yes Address glob identifying which blocks get the attached files (e.g., 'module.foo.*'). Uses the same glob grammar as --force.
--workspace Yes Workspace whose config entry to modify

Arguments

Argument Required Description
<file-glob>... Yes One or more file globs to attach at the given address

Example

stategraph config files attach --workspace default --address 'module.app.*' './templates/*.tpl'
Attached 1 glob(s) at module.app.* for workspace default

The resulting stategraph.json:

{
  "workspaces": {
    "default": {
      "attached_files": {
        "module.app.*": { "globs": [ "./templates/*.tpl" ] }
      }
    }
  }
}

Commit stategraph.json so the mappings travel with the module.

stategraph config files remove

Remove file globs from an address glob under a workspace. With no globs, removes the entire address entry.

stategraph config files remove --workspace <workspace> --address <address-glob> [<file-glob>...]

Options

Option Required Description
--address Yes Address glob to modify
--workspace Yes Workspace whose config entry to modify

Arguments

Argument Required Description
<file-glob>... No File globs to remove. When omitted, the entire address entry is removed.

Examples

# Remove one glob
stategraph config files remove --workspace default --address 'module.app.*' './templates/*.tpl'

# Remove the whole address entry
stategraph config files remove --workspace default --address 'module.app.*'

The same mappings can be set at import time with stategraph import tf --attach-files. For paths Stategraph cannot resolve statically, --force-files on stategraph tf plan and stategraph import tf is the blunt-instrument alternative — it attaches every matching file to every file-reading call instead of specific addresses.

Next Steps