{"id":48345772,"url":"https://github.com/confstack/terraform-provider-confstack","last_synced_at":"2026-04-09T03:01:07.523Z","repository":{"id":349269365,"uuid":"1201690039","full_name":"confstack/terraform-provider-confstack","owner":"confstack","description":"A Terraform/OpenTofu provider for managing layered, deep-merged, and templated configurations.","archived":false,"fork":false,"pushed_at":"2026-04-05T06:06:24.000Z","size":167,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-05T07:02:17.168Z","etag":null,"topics":["configuration","devops","iac","opentofu","terraform"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/confstack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-05T02:47:38.000Z","updated_at":"2026-04-05T06:05:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"7e83d487-57d6-45a3-a429-e7a2b88fb289","html_url":"https://github.com/confstack/terraform-provider-confstack","commit_stats":null,"previous_names":["confstack/terraform-provider-confstack"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/confstack/terraform-provider-confstack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/confstack%2Fterraform-provider-confstack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/confstack%2Fterraform-provider-confstack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/confstack%2Fterraform-provider-confstack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/confstack%2Fterraform-provider-confstack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/confstack","download_url":"https://codeload.github.com/confstack/terraform-provider-confstack/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/confstack%2Fterraform-provider-confstack/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31583290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","devops","iac","opentofu","terraform"],"created_at":"2026-04-05T07:00:31.636Z","updated_at":"2026-04-09T03:01:07.481Z","avatar_url":"https://github.com/confstack.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# ConfStack - Terraform/OpenTofu Provider \n\n**Merge ordered YAML layers into a single Terraform configuration object**\n\n![Terraform](https://img.shields.io/badge/terraform-%235835CC.svg?style=for-the-badge\u0026logo=terraform\u0026logoColor=white)\n\n\u003c/div\u003e\n\n---\n\n## What is confstack?\n\nconfstack brings a **GitOps approach to Terraform configuration**. Inspired by [Helmfile](https://helmfile.readthedocs.io/en/latest/)'s layered values, it lets you describe infrastructure parameters as an ordered stack of YAML files — a base layer, an environment layer, a tenant layer, whatever fits your setup — then merges them into a single Terraform object that your HCL can reference.\n\nYour YAML files live alongside your Terraform code (or in a dedicated config repo), get reviewed and merged through pull requests, and drive infrastructure changes through your CI/CD pipeline. Environment promotions become a YAML file addition. Configuration differences between tenants no longer require HCL conditionals. Every change has a Git history.\n\nThe provider handles the merging mechanics: recursive deep merge, Go template injection for variables and secrets (`var`/`secret`), and template inheritance for DRY patterns (`_templates`/`_inherit`).\n\n---\n\n## Quick Start\n\n**Step 1 — Install the provider**\n\n```hcl\nterraform {\n  required_providers {\n    confstack = {\n      source  = \"confstack/confstack\"\n      version = \"~\u003e 1.0\"\n    }\n  }\n}\n\nprovider \"confstack\" {}\n```\n\n**Step 2 — Write your YAML layers**\n\n```yaml\n# config/base.yaml\ntags:\n  managed_by: opentofu\n  team: platform\n\neks:\n  node_size: t3.medium\n  min_nodes: 2\n```\n\n```yaml\n# config/prod.yaml\ntags:\n  environment: prod\n\neks:\n  node_size: m5.xlarge   # overrides base\n  min_nodes: 3\n```\n\n**Step 3 — Declare the data source**\n\n```hcl\ndata \"confstack_layered_config\" \"app\" {\n  layers = [\n    \"${path.module}/config/base.yaml\",\n    \"${path.module}/config/${var.environment}.yaml\",\n  ]\n  on_missing_layer = \"skip\"   # silently ignore absent layer files\n}\n```\n\n**Step 4 — Use the output**\n\n```hcl\n# Nested access\noutput \"node_size\" {\n  value = data.confstack_layered_config.app.config.eks.node_size\n  # → \"m5.xlarge\" in prod\n}\n\n# Flat access (all values as strings)\nresource \"aws_eks_node_group\" \"main\" {\n  instance_types = [data.confstack_layered_config.app.flat_config[\"eks.node_size\"]]\n}\n```\n\n---\n\n## Data Source: `confstack_layered_config`\n\n### Inputs\n\n| Attribute | Type | Required | Default | Description |\n|---|---|---|---|---|\n| `layers` | `list(string)` | yes | — | Ordered YAML file paths. Index 0 is lowest priority; last is highest (last wins). |\n| `on_missing_layer` | `string` | no | `\"error\"` | How to handle a missing file. One of `\"error\"`, `\"warn\"`, `\"skip\"`. |\n| `variables` | `map(string)` | no | `{}` | Values injected via `{{ var \"KEY\" }}` in YAML templates. Checks this map first, then OS environment. |\n| `secrets` | `map(string)` | no | `{}` | Sensitive values injected via `{{ secret \"KEY\" }}`. Marked sensitive in Terraform. Checks this map first, then OS environment. |\n| `flat_separator` | `string` | no | `\".\"` | Separator used when flattening nested keys into `flat_config`. |\n\n### Outputs\n\n| Attribute | Type | Sensitive | Description |\n|---|---|---|---|\n| `config` | `dynamic` | no | Fully resolved config. Secrets are redacted as `\"(sensitive)\"`. |\n| `sensitive_config` | `dynamic` | yes | Same as `config` but with secrets in plaintext. |\n| `flat_config` | `map(string)` | no | `config` flattened to `flat_separator`-delimited keys. All values converted to strings. |\n| `loaded_layers` | `list(string)` | no | Paths of layer files that were successfully loaded. |\n| `secret_paths` | `list(string)` | no | Dot-delimited paths in `config` that contain secret values. |\n\n---\n\n## Layer Merge Behavior\n\nLayers are merged in index order — **index 0 is the base (lowest priority), the last entry wins**. Within each merge:\n\n| Value type | Merge strategy |\n|---|---|\n| Map | Recursively merged; new keys are added, existing keys are overridden |\n| Scalar (string, number, bool) | Replaced entirely by the higher-priority value |\n| List | Replaced entirely (not concatenated) |\n| `null` | Deletes the key from the result (applied predictably at every layer). |\n\n```yaml\n# base.yaml\ntags:\n  managed_by: opentofu\n  environment: dev\nitems: [a, b]\n\n# prod.yaml\ntags:\n  environment: prod   # overrides; managed_by is kept\nitems: [c]            # replaces the whole list\nto_delete: ~          # null deletes the key\n```\n\nResult after `layers = [base.yaml, prod.yaml]`:\n\n```yaml\ntags:\n  managed_by: opentofu\n  environment: prod\nitems: [c]\n# to_delete is gone\n```\n\n---\n\n## Templating\n\nYAML files are processed as [Go templates](https://pkg.go.dev/text/template) before YAML parsing. The full [Sprig](http://masterminds.github.io/sprig/) function library is available.\n\n### `var \"KEY\"` — inject a variable\n\nLooks up `KEY` in `variables`, then falls back to the OS environment. Errors if the key is missing in both. Outputs a JSON-encoded string (safe for YAML contexts).\n\n```yaml\nnetwork:\n  vpc_id: {{ var \"VPC_ID\" }}\n```\n\n### `secret \"KEY\"` — inject a secret\n\nSame lookup order as `var`, but the value becomes `\"(sensitive)\"` in `config` and the real value in `sensitive_config`. The path is recorded in `secret_paths`.\n\n```yaml\ndatabase:\n  password: {{ secret \"DB_PASSWORD\" }}\n```\n\n### Sprig functions\n\nAll Sprig functions are available, including `upper`, `lower`, `default`, `trimAll`, `toJson`, and many more. For example:\n\n```yaml\nname: {{ var \"SERVICE_NAME\" | lower | replace \"_\" \"-\" }}\n```\n\n\u003e **Note:** Sprig's `env \"KEY\"` function also reads OS environment variables directly, but it returns an empty string if the key is missing (no error) and does not consult the `variables` map. Prefer `var \"KEY\"` for consistent error handling.\n\n---\n\n## Inheritance (`_templates` / `_inherit`)\n\nDefine reusable config blocks with `_templates` and apply them with `_inherit`. Templates are collected globally from all loaded layers.\n\n```yaml\nsqs_queues:\n  _templates:\n    standard:\n      retention: 86400\n      dlq: true\n      visibility_timeout: 30\n    critical:\n      retention: 604800\n      dlq: true\n      visibility_timeout: 30\n      dlq_max_retries: 5\n\n  # Single template\n  notifications:\n    _inherit: standard\n    retention: 3600        # entry-level override applied after inheriting\n\n  # Multiple templates + key exclusion\n  orders:\n    _inherit:\n      - template: standard\n        except: [dlq]      # skip dlq from standard\n      - template: critical # then merge all of critical on top\n```\n\nRules:\n\n- `_inherit` accepts a string (single template name), a list of strings, or a list of `{template, except}` objects.\n- Templates are merged left-to-right; the entry's own keys always win last.\n- Template names must be globally unique across all loaded layers.\n- Templates cannot themselves contain `_inherit`.\n- `_templates` and `_inherit` are stripped from all outputs.\n\n---\n\n## Flat Output\n\n`flat_config` collapses all nested keys into a `map(string)` using `flat_separator` (default `.`). All values are converted to their string representation. This is useful for passing individual values directly to resource arguments.\n\n```hcl\ndata \"confstack_layered_config\" \"app\" {\n  layers         = [\"${path.module}/config/base.yaml\"]\n  flat_separator = \"/\"   # optional; use \"/\" for URL-safe keys\n}\n\nresource \"aws_db_instance\" \"main\" {\n  address = data.confstack_layered_config.app.flat_config[\"database/host\"]\n  port    = data.confstack_layered_config.app.flat_config[\"database/port\"]\n}\n```\n\n---\n\n## Missing Layer Handling\n\n| `on_missing_layer` | Behavior when a layer file is absent |\n|---|---|\n| `\"error\"` (default) | Error — plan/apply fails immediately. |\n| `\"warn\"` | Warning logged; layer is skipped. Resolution continues. |\n| `\"skip\"` | Layer silently skipped. Resolution continues. |\n\nCombine `on_missing_layer = \"skip\"` with `compact()` to build dynamic, optional layer stacks:\n\n```hcl\ndata \"confstack_layered_config\" \"app\" {\n  layers = compact([\n    \"${path.module}/config/base.yaml\",\n    \"${path.module}/config/${var.environment}.yaml\",\n    var.tenant != \"\" ? \"${path.module}/config/tenants/${var.tenant}.yaml\" : \"\",\n  ])\n  on_missing_layer = \"skip\"\n}\n```\n\n---\n\n## Development \u0026 Versioning\n\nThis provider uses [Conventional Commits](https://www.conventionalcommits.org/) for automated semantic versioning and changelog generation.\n\n| Prefix | Type | Resulting Version Change |\n|---|---|---|\n| `feat:` | Feature | Minor (e.g., 1.0.0 → 1.1.0) |\n| `fix:` | Bug Fix | Patch (e.g., 1.0.0 → 1.0.1) |\n| `perf:`, `refactor:`, `chore:` | Internal | Patch (if it affects built files) or no release |\n| `BREAKING CHANGE:` | Breaking | Major (e.g., 1.0.0 → 2.0.0) |\n\nCommits to the `main` branch will automatically trigger a new version tag and GitHub release if a version-worthy change is detected.\n\n---\n\n## Examples\n\n| Example | Description |\n|---|---|\n| [`basic/`](examples/data-sources/confstack_layered_config/basic/) | Two-layer merge (base + environment override) |\n| [`multi-environment/`](examples/data-sources/confstack_layered_config/multi-environment/) | Dynamic environment layer with `on_missing_layer = \"skip\"` |\n| [`inheritance/`](examples/data-sources/confstack_layered_config/inheritance/) | `_templates` / `_inherit` for DRY configuration |\n| [`templating/`](examples/data-sources/confstack_layered_config/templating/) | `var()` / `secret()` template injection |\n| [`flat-output/`](examples/data-sources/confstack_layered_config/flat-output/) | `flat_config` for ergonomic resource attribute access |\n| [`complete/`](examples/data-sources/confstack_layered_config/complete/) | Full multi-layer stack with env, tenant, `compact()`, secrets |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconfstack%2Fterraform-provider-confstack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconfstack%2Fterraform-provider-confstack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconfstack%2Fterraform-provider-confstack/lists"}