Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Repository files navigation

Terraform Data Environment Module

This module exposes Terraform Cloud/Enterprise (TFC/TFE) environment data, module versions, and runtime system diagnostics. It is designed to provide context for governance (Sentinel/OPA), debugging, and dynamic Terraform logic. t3tw

Features

  • TFC/TFE Metadata: Exposes workspace name, ID, slug, project name, organization, and run ID as structured outputs.
  • VCS Information: Provides Git commit SHA, branch, and repository URL if available in the environment.
  • Module Inspection: Reads .terraform/modules/modules.json to expose version information of installed modules for policy enforcement.
  • System Diagnostics (Optional): Fetches runtime information about the Terraform runner (OS, kernel, user, disk usage, installed tools) using an external data source.

Usage

module "data_env" {
  source = "abuxton/terraform-data-env"

  # Optional Feature Flags
  enable_system_info        = true  # Enable external data source for system diagnostics
  enable_debug_provisioners = false # Enable local-exec echo commands for debugging
}

Inputs

Name Description Type Default
enable_system_info Enable external data source to fetch system information (OS, IP, Disk, etc). bool false
enable_debug_provisioners Enable debug local-exec provisioners that print system info to stdout. bool false
demo_module_bool Boolean whether to use demo module or not. bool false

Outputs

TFC/TFE Metadata

  • workspace_name, workspace_slug, organization
  • project_name, run_id
  • is_remote: Boolean indicating if running in TFC/TFE.

VCS Metadata

  • vcs_commit_sha
  • vcs_branch
  • vcs_repo_url

System Diagnostics (Requires enable_system_info = true)

  • sys_os_release: OS version of the runner.
  • sys_kernel_version: Kernel version.
  • sys_current_user: User executing the run (e.g., tfc-agent).
  • sys_ip_address: Primary IP address.
  • sys_disk_usage_root: Disk usage of /.
  • sys_installed_tools: Versions of git, terraform, and jq.

Module Data

  • modules_json: Raw content of .terraform/modules/modules.json.
  • environment_data_all: All environment variables (raw map).

Governance & Policy Usage

The exposed data is particularly useful for Sentinel or OPA policies.

Example: Sentinel Mock Data The module exposes structure that can be used to mock state for policy checks:

"modules_json": {
  "value": {
    "Modules": [
      {
        "Key": "helloworld",
        "Source": "registry.terraform.io/briancain/helloworld/aws",
        "Version": "2020.4.21"
      }
    ]
  }
}

Requirements

Name Version
Terraform ~> 1.9
epp0/environment ~> 1.3

Copilot & Agents

This project includes configuration for GitHub Copilot.

  • See AGENTS.md for detailed development workflows, setup instructions, and release processes.
  • See .github/copilot-instructions.md for coding standards and agent personas used in this repository.

Skills

a skills-lock.json is included run npx -yes skills experimental_install -p -y to reinstall the implied agent skills for the project.

Authors

Currently maintained by these contributors.

License

MIT License. See LICENSE for full details.

Requirements

Name Version
terraform >= 1.9
environment ~> 1.3
external ~> 2.3

Providers

Name Version
environment ~> 1.3
external ~> 2.3
local n/a
terraform n/a

Modules

Name Source Version
helloworld briancain/helloworld/aws ~> 2020.4

Resources

Name Type
terraform_data.test resource
environment_variables.all data source
external_external.sys_info data source
local_file.modules_json data source

Inputs

Name Description Type Default Required
demo_module_bool (Optional) Boolean whether to use demo module or not bool false no
enable_debug_provisioners (Optional) Enable debug local-exec provisioners for system discovery. WARNING: This runs commands that capture environment variables and host diagnostics and may leak secrets or other sensitive runtime details into CI/Terraform Cloud logs. Use only for temporary troubleshooting and disable afterwards. bool false no
enable_system_info (Optional) Enable external data source to fetch system information. bool false no

Outputs

Name Description
environment_data_all All environment variables, derived from Epp0/environment provider
is_remote Boolean indicating if the run is executing in Terraform Cloud/Enterprise.
modules_json The content of the modules.json file
organization The name of the Terraform Cloud/Enterprise organization.
project_name The name of the Terraform Cloud/Enterprise project.
run_id The ID of the Terraform Cloud/Enterprise run.
sys_current_user The user executing the Terraform run.
sys_disk_usage_root Disk usage of the root partition on the runner.
sys_installed_tools Versions of key tools (git, terraform, jq) installed on the runner.
sys_ip_address The primary IP address of the Terraform runner.
sys_kernel_version The kernel version of the Terraform runner.
sys_os_release The operating system release information of the Terraform runner.
vcs_branch The Git branch of the configuration version.
vcs_commit_sha The Git commit SHA of the configuration version.
vcs_repo_url The Git repository URL of the configuration version.
workspace_name The name of the Terraform Cloud/Enterprise workspace.
workspace_slug The slug of the Terraform Cloud/Enterprise workspace.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages