Problem: AI agents and deployments leave behind long-lived credentials after their work ends. AWS IAM user access keys never expire automatically, and OWASP ranks improper offboarding first in its 2025 Non-Human Identities Top 10. An unowned credential grants access indefinitely, unlike an idle resource that merely costs money.
Discovery: Sync AWS IAM credential reports into CloudQuery's aws_iam_credential_reports and run a SQL query (ClickHouse and PostgreSQL variants provided) that unnests both key slots per IAM user and lists active keys >90 days old, unused ≥90 days. The 90-day window is a review threshold, not a verdict; the report lacks key IDs and ownership, so correlate with audit logs and named owners. Similar inventories exist for Entra ID service principals and GCP service-account keys, though GCP inventory alone doesn't show usage.
Prevention: An env zero Rego approval policy (OPA, compatible with 0.46.1 and 1.x) inspects Terraform/OpenTofu plans — including Terragrunt run-all — and denies creation of long-lived credential resources (aws_iam_access_key, google_service_account_key, AzureAD passwords/certificates, etc.). Enforcement only happens at deploy/destroy on env zero–governed deployments; unrecognized plan shapes are denied, but console-created keys, Pulumi/CloudFormation, and hardcoded secrets aren't caught. Federation/OIDC with temporary credentials is preferred.
Expiry: AWS keys have no expiration, so use environment TTLs for teardown — but TTLs aren't credential expiry: failed destroys, manual keys, admin overrides, or Free-plan limits (250 runs/month) can leave access behind. Retire outside-lifecycle keys deliberately via aws iam update-access-key --status Inactive, observe for authentication errors matched to workload schedules, then delete irreversibly under change control. Terraform-managed keys also persist secrets in state.