AI coding agents and a Terraform MCP server are far more useful when they can see your private module registry: they suggest your modules, with your inputs, instead of inventing resources from scratch.
The risk is the credential. A Terraform Cloud token with workspace access can plan and apply. An agent holding that token, steered by a bad prompt, could change real infrastructure.
So the agents get their own identity:
- A dedicated team with no workspace grants at all. Its token can read the private registry, and that's the only thing it can do.
- No apply, no plan, no state access. If an agent is compromised or misled, the worst case is reading module documentation.
- Separate from human and pipeline tokens, so it can be rotated or revoked without touching anything else.
resource "tfe_team" "agents_readonly" {
name = "agents-readonly"
organization = var.organization
visibility = "secret"
}
# No tfe_team_access resources: this team has no workspace permissions.
resource "tfe_team_token" "agents_readonly" {
team_id = tfe_team.agents_readonly.id
}
The principle isn't new: give each workload exactly the access its job needs. It matters more when the workload takes instructions from text.