Terraform for self-managed Kong Gateway
Goal
Author or revise Terraform-managed self-managed Kong Gateway entities while
preserving the repository's current module layout, provider model, and state
ownership.
Use this skill once Terraform is already the right tool for Admin API-backed
self-managed Gateway work. Do not use it as the default for Konnect platform
resources or for design and troubleshooting work that should happen before
tool-specific HCL changes.
Tool Positioning
- Use this skill when the repository already uses Terraform for self-managed
Gateway resources or the user explicitly asks for Terraform.
- This skill owns HCL authoring, import-first adoption, plan review, and
Terraform-native proof after the Terraform path is chosen.
- Preserve existing Terraform modules, variables, backend settings, and
workspaces.
- Use the official
kong/kong-gateway provider for self-managed Gateway
resources reachable through the Admin API.
- Hand off to
deck-gateway when the user wants file-based Gateway GitOps,
dump/diff workflows, or a decK-native repository.
- Hand off to
terraform-konnect when the target resources actually belong to
Konnect rather than a self-managed Admin API surface.
- Hand off to Gateway or product-specific diagnosis skills when the harder
problem is gateway health, plugin behavior, or design intent rather than HCL
ownership.
References To Load
Load only the reference file that matches the active branch:
references/provider-and-import.md
- Load when provider inputs, existing live resources, or import-first
handling is the main question.
references/entity-patterns.md
- Load when the user is deciding how self-managed Gateway entities should be
grouped or modeled in the existing HCL layout.
references/plan-safety-and-state.md
- Load when the main issue is how to inspect plan impact safely before
applying to a live Admin API surface.
references/provider-schema-debugging.md
- Load when nested resource shape is unclear, validation reports
object-vs-string or similar type mismatches, or provider behavior does not
line up cleanly with docs or example HCL.
Validation Contract
Preflight
Before writing HCL or proposing a plan:
- Confirm Terraform is installed and runnable.
- Confirm the target Admin API endpoint and auth method already exist.
- Inspect provider blocks, backend settings, workspace selection, and module
conventions before adding HCL.
- Keep Admin API tokens and secrets out of committed files.
- Confirm whether existing live Gateway entities must be imported before
planning.
- Use
terraform providers schema -json as the default source of truth when
nested resource shape is unclear before guessing from docs or examples
Preview
Use Terraform's native preview surface before apply:
- run the repo's normal format and validation checks when they exist
- run
terraform validate
- run
terraform plan
- import first when a live Service, Route, plugin, or other entity already
exists and should be brought under state
- check the exact resource addresses, environment, and create-update-destroy
shape before considering apply
Execute
- Describe the intended effect before any mutating command.
- Run
terraform apply only when the user explicitly asked for live mutation.
- Keep apply scoped to the same directory, workspace, and variable inputs that
were previewed.
Prove
After a requested apply:
- confirm the intended resource addresses are now present in Terraform state
- inspect key addresses with
terraform state show <address> or the repo's
normal output surface
- when practical, run a follow-up
terraform plan and expect no remaining
intended changes for the touched slice
- do not treat apply success by itself as proof that the live Gateway matches
intent
Operating Rules
- Preserve existing HCL layout, resource grouping, and variable usage.
- Use
terraform providers schema -json as the default source of truth for
unknown nested resource shape before guessing HCL from docs or examples.
- Prefer
terraform plan before terraform apply unless the user explicitly
asks for direct execution.
- If
terraform providers schema -json, provider startup, terraform validate,
or terraform plan fails in a way that suggests sandbox interference,
retry outside the sandbox with approval before treating it as a provider,
auth, or schema problem.
- Prefer importing existing Gateway resources over recreating them.
- Keep the scope limited to the Gateway entities requested by the user.
- Do not mix self-managed Gateway assumptions into Konnect tasks.
- When the repository already uses
decK, do not switch it to Terraform unless
migration is the task.
- Do not treat a successful
terraform apply as proof by itself; follow with
state or plan-based verification of the touched addresses.
Workflow
1. Classify the ownership boundary
Establish whether the task is actually:
- self-managed Gateway Admin API configuration that this skill should own
- Konnect platform configuration that belongs to
terraform-konnect
- a
decK-native Gateway workflow that belongs to deck-gateway
- gateway behavior or design diagnosis that should be resolved before
Terraform-specific implementation
Do not write HCL until that split is clear.
2. Inspect the Terraform shape
Identify:
- root and child modules
- provider aliases
- backend or remote state configuration
- variable files and secrets conventions
- existing ownership boundaries for services, routes, plugins, consumers, or
certificates
3. Confirm the target Gateway surface
Pin down:
- which Admin API endpoint is in scope
- which Gateway entities are being managed
- whether the task is create, update, import, or drift correction
Load references/provider-and-import.md when provider inputs, import-first
adoption, or Admin API targeting is the real uncertainty.
4. Choose the narrow implementation path
Default paths:
- new managed entity: add HCL in the existing module layout
- existing unmanaged entity: import first, then normalize the HCL
- large-scale file-based Gateway GitOps: consider
deck-gateway instead of
forcing Terraform if that matches the user's intent better
Load references/entity-patterns.md when repo ownership shape is the harder
question. Load references/provider-schema-debugging.md when resource shape is
the main uncertainty.
5. Author HCL with minimal churn
- reuse existing variables and locals
- keep names and identifiers stable
- avoid broad refactors while making a narrow Gateway change
- add outputs only when another module or pipeline consumes them
- inspect
terraform providers schema -json before guessing nested block or
attribute structure
6. Preview before any apply path
- run the repo's normal format and validation checks when they exist
- run
terraform validate
- run
terraform plan
- import first if the plan would recreate an entity that already exists live
- inspect whether the plan touches only the intended addresses and workspace
Load references/plan-safety-and-state.md when the operator needs a safer
inspection-first path before touching a live Gateway.
7. Execute only when requested
- Describe the intended live effect before presenting or running
terraform apply.
- Use the same directory, workspace, and variable inputs that produced the
reviewed plan.
- Run
terraform apply only when the user explicitly asked to mutate live
Gateway state.
8. Prove the result with Terraform-native checks
After any requested terraform apply:
- confirm the touched resource addresses now appear in
terraform state list
- inspect key addresses with
terraform state show <address> or the repo's
normal outputs
- when practical, run a follow-up
terraform plan and expect no remaining
intended changes for the affected slice
- call out remaining drift or ownership surprises instead of hiding them behind
apply success
9. Report config and state impact
State:
- which files or modules changed
- which Gateway entities are affected
- whether import is required
- whether the next step is
plan, apply, or external verification
Kong-Specific Gotchas
- Terraform state is not a substitute for checking what the live Gateway
already has; import matters.
- Recreating existing plugins, services, or routes can cause avoidable
identifier churn.
- Provider docs and Gateway examples can describe intent, but the Terraform
provider schema is the authoritative shape for nested HCL.
- Some teams use Terraform for infrastructure but
decK for Gateway entities;
preserve the established split if it already exists.
- A self-managed Admin API workflow is not the same as a Konnect control plane
workflow even if the resource names look similar.
Validation Checklist
Before answering, verify that you can state:
- why Terraform is the right tool for this repository or request
- which Admin API-backed Gateway surface is in scope
- which module or file owns the resources
- whether import is required
- which preview commands prove the intended change before mutation
- whether provider schema inspection is needed before guessing nested HCL shape
- whether the task stops at HCL authoring or continues to
plan/apply
- how the touched resource addresses will be proved after apply
- whether
deck-gateway would be a better fit for the user's intent
Handoffs
- Use
deck-gateway when the user wants decK-native Gateway GitOps or live
Gateway export/diff workflows.
- Use
terraform-konnect when the resources actually belong to Konnect.
- Use Gateway or product-specific domain skills when the user first needs
troubleshooting or design help rather than HCL authoring.
Source: johnharris85/kong-skills — distributed by TomeVault.
1---2name: terraform-kong-gateway3description: Use when editing or reviewing Terraform that manages self-managed Kong Gateway Admin API entities with the official `kong/kong-gateway` provider; not for Konnect resources, decK-native Gateway GitOps, or gateway troubleshooting before tool choice.4---56# Terraform for self-managed Kong Gateway78## Goal910Author or revise Terraform-managed self-managed Kong Gateway entities while11preserving the repository's current module layout, provider model, and state12ownership.1314Use this skill once Terraform is already the right tool for Admin API-backed15self-managed Gateway work. Do not use it as the default for Konnect platform16resources or for design and troubleshooting work that should happen before17tool-specific HCL changes.1819## Tool Positioning2021- Use this skill when the repository already uses Terraform for self-managed22 Gateway resources or the user explicitly asks for Terraform.23- This skill owns HCL authoring, import-first adoption, plan review, and24 Terraform-native proof after the Terraform path is chosen.25- Preserve existing Terraform modules, variables, backend settings, and26 workspaces.27- Use the official `kong/kong-gateway` provider for self-managed Gateway28 resources reachable through the Admin API.29- Hand off to `deck-gateway` when the user wants file-based Gateway GitOps,30 dump/diff workflows, or a `decK`-native repository.31- Hand off to `terraform-konnect` when the target resources actually belong to32 Konnect rather than a self-managed Admin API surface.33- Hand off to Gateway or product-specific diagnosis skills when the harder34 problem is gateway health, plugin behavior, or design intent rather than HCL35 ownership.3637## References To Load3839Load only the reference file that matches the active branch:4041- `references/provider-and-import.md`42 - Load when provider inputs, existing live resources, or import-first43 handling is the main question.44- `references/entity-patterns.md`45 - Load when the user is deciding how self-managed Gateway entities should be46 grouped or modeled in the existing HCL layout.47- `references/plan-safety-and-state.md`48 - Load when the main issue is how to inspect plan impact safely before49 applying to a live Admin API surface.50- `references/provider-schema-debugging.md`51 - Load when nested resource shape is unclear, validation reports52 object-vs-string or similar type mismatches, or provider behavior does not53 line up cleanly with docs or example HCL.5455## Validation Contract5657### Preflight5859Before writing HCL or proposing a plan:6061- Confirm Terraform is installed and runnable.62- Confirm the target Admin API endpoint and auth method already exist.63- Inspect provider blocks, backend settings, workspace selection, and module64 conventions before adding HCL.65- Keep Admin API tokens and secrets out of committed files.66- Confirm whether existing live Gateway entities must be imported before67 planning.68- Use `terraform providers schema -json` as the default source of truth when69 nested resource shape is unclear before guessing from docs or examples7071### Preview7273Use Terraform's native preview surface before apply:7475- run the repo's normal format and validation checks when they exist76- run `terraform validate`77- run `terraform plan`78- import first when a live Service, Route, plugin, or other entity already79 exists and should be brought under state80- check the exact resource addresses, environment, and create-update-destroy81 shape before considering apply8283### Execute8485- Describe the intended effect before any mutating command.86- Run `terraform apply` only when the user explicitly asked for live mutation.87- Keep apply scoped to the same directory, workspace, and variable inputs that88 were previewed.8990### Prove9192After a requested apply:9394- confirm the intended resource addresses are now present in Terraform state95- inspect key addresses with `terraform state show <address>` or the repo's96 normal output surface97- when practical, run a follow-up `terraform plan` and expect no remaining98 intended changes for the touched slice99- do not treat apply success by itself as proof that the live Gateway matches100 intent101102## Operating Rules103104- Preserve existing HCL layout, resource grouping, and variable usage.105- Use `terraform providers schema -json` as the default source of truth for106 unknown nested resource shape before guessing HCL from docs or examples.107- Prefer `terraform plan` before `terraform apply` unless the user explicitly108 asks for direct execution.109- If `terraform providers schema -json`, provider startup, `terraform validate`,110 or `terraform plan` fails in a way that suggests sandbox interference,111 retry outside the sandbox with approval before treating it as a provider,112 auth, or schema problem.113- Prefer importing existing Gateway resources over recreating them.114- Keep the scope limited to the Gateway entities requested by the user.115- Do not mix self-managed Gateway assumptions into Konnect tasks.116- When the repository already uses `decK`, do not switch it to Terraform unless117 migration is the task.118- Do not treat a successful `terraform apply` as proof by itself; follow with119 state or plan-based verification of the touched addresses.120121## Workflow122123### 1. Classify the ownership boundary124125Establish whether the task is actually:126127- self-managed Gateway Admin API configuration that this skill should own128- Konnect platform configuration that belongs to `terraform-konnect`129- a `decK`-native Gateway workflow that belongs to `deck-gateway`130- gateway behavior or design diagnosis that should be resolved before131 Terraform-specific implementation132133Do not write HCL until that split is clear.134135### 2. Inspect the Terraform shape136137Identify:138139- root and child modules140- provider aliases141- backend or remote state configuration142- variable files and secrets conventions143- existing ownership boundaries for services, routes, plugins, consumers, or144 certificates145146### 3. Confirm the target Gateway surface147148Pin down:149150- which Admin API endpoint is in scope151- which Gateway entities are being managed152- whether the task is create, update, import, or drift correction153154Load `references/provider-and-import.md` when provider inputs, import-first155adoption, or Admin API targeting is the real uncertainty.156157### 4. Choose the narrow implementation path158159Default paths:160161- new managed entity: add HCL in the existing module layout162- existing unmanaged entity: import first, then normalize the HCL163- large-scale file-based Gateway GitOps: consider `deck-gateway` instead of164 forcing Terraform if that matches the user's intent better165166Load `references/entity-patterns.md` when repo ownership shape is the harder167question. Load `references/provider-schema-debugging.md` when resource shape is168the main uncertainty.169170### 5. Author HCL with minimal churn171172- reuse existing variables and locals173- keep names and identifiers stable174- avoid broad refactors while making a narrow Gateway change175- add outputs only when another module or pipeline consumes them176- inspect `terraform providers schema -json` before guessing nested block or177 attribute structure178179### 6. Preview before any apply path180181- run the repo's normal format and validation checks when they exist182- run `terraform validate`183- run `terraform plan`184- import first if the plan would recreate an entity that already exists live185- inspect whether the plan touches only the intended addresses and workspace186187Load `references/plan-safety-and-state.md` when the operator needs a safer188inspection-first path before touching a live Gateway.189190### 7. Execute only when requested191192- Describe the intended live effect before presenting or running193 `terraform apply`.194- Use the same directory, workspace, and variable inputs that produced the195 reviewed plan.196- Run `terraform apply` only when the user explicitly asked to mutate live197 Gateway state.198199### 8. Prove the result with Terraform-native checks200201After any requested `terraform apply`:202203- confirm the touched resource addresses now appear in `terraform state list`204- inspect key addresses with `terraform state show <address>` or the repo's205 normal outputs206- when practical, run a follow-up `terraform plan` and expect no remaining207 intended changes for the affected slice208- call out remaining drift or ownership surprises instead of hiding them behind209 apply success210211### 9. Report config and state impact212213State:214215- which files or modules changed216- which Gateway entities are affected217- whether import is required218- whether the next step is `plan`, `apply`, or external verification219220## Kong-Specific Gotchas221222- Terraform state is not a substitute for checking what the live Gateway223 already has; import matters.224- Recreating existing plugins, services, or routes can cause avoidable225 identifier churn.226- Provider docs and Gateway examples can describe intent, but the Terraform227 provider schema is the authoritative shape for nested HCL.228- Some teams use Terraform for infrastructure but `decK` for Gateway entities;229 preserve the established split if it already exists.230- A self-managed Admin API workflow is not the same as a Konnect control plane231 workflow even if the resource names look similar.232233## Validation Checklist234235Before answering, verify that you can state:236237- why Terraform is the right tool for this repository or request238- which Admin API-backed Gateway surface is in scope239- which module or file owns the resources240- whether import is required241- which preview commands prove the intended change before mutation242- whether provider schema inspection is needed before guessing nested HCL shape243- whether the task stops at HCL authoring or continues to `plan/apply`244- how the touched resource addresses will be proved after apply245- whether `deck-gateway` would be a better fit for the user's intent246247## Handoffs248249- Use `deck-gateway` when the user wants `decK`-native Gateway GitOps or live250 Gateway export/diff workflows.251- Use `terraform-konnect` when the resources actually belong to Konnect.252- Use Gateway or product-specific domain skills when the user first needs253 troubleshooting or design help rather than HCL authoring.254255---256> Source: [johnharris85/kong-skills](https://github.com/johnharris85/kong-skills) — distributed by [TomeVault](https://tomevault.io).257<!-- tomevault:4.0:skill_md:2026-05-22 -->