AWS_IAM auth policy, an optional Aurora vault, an Object Lock audit bucket, CMK-encrypted log groups and optional VPC endpoints. No NAT, no internet route, no shared secret.
When to use it
You manage infrastructure with Terraform and want ECS. Requires Terraform ≥ 1.11 with thehashicorp/aws provider ~> 6.0 and hashicorp/time ~> 0.13. The module has no backend and no provider block — configure both in your root module.
Wire the module into a root module, plan, and stop for review before apply.
Usage
Download the module and extract it next to your configuration. Pointsource at the extracted folder.
c9g.xlarge, so the default needs 8 vCPUs, 12 with rehydration.
main.tf
Calling the services
detect_endpoint and rehydrate_endpoint are https://<service>.vpc-lattice-svcs.<region>.on.aws. For each caller:
- Network. Attach
lattice_client_security_group_idto the caller (ENI, Lambda, ECS task); its only egress is tcp/443 to thecom.amazonaws.<region>.vpc-latticeprefix list. The caller’s VPC must be associated with the service network — the module associatesvpc_idwhen it creates the network; withexisting_service_network_arnyou manage associations yourself — and listed inallowed_source_vpc_ids(default[vpc_id]). - Identity policy. Attach
detect_caller_policy(detect and erasure callers) orrehydrate_caller_policyto the caller’s role. A same-account caller needs this and the service auth policy; either alone is a403. - Signing. SigV4 with service
vpc-lattice-svcsandx-amz-content-sha256: UNSIGNED-PAYLOAD. Thetenet-pii-latticeclient does this (pip install https://platform.tenetlabs.com/enterprise/current/tenet_pii_lattice.tar.gz); plain botocoreSigV4Authworks, noawscrtneeded. Reuse connections — each new connection pays a TLS handshake.
POST /detect, /redact, /deidentify and (for erasure invokers) DELETE /sessions/{session_id}; rehydrate accepts only POST /reidentify. Anything else is a Lattice 404 or 403 and never reaches a task. With require_rehydrate_approval_tag, every /reidentify must come from a session tagged tenet-approval-id — Lattice checks it, because it doesn’t forward session tags. The break-glass role (MFA) may call /reidentify without the tag.
Both roles audit to the Object Lock bucket: rehydrate under audit_prefix, detect (erasures) under erasure_audit_prefix. Lattice access logs for both services go to /<name_prefix>/lattice; join them to audit records on upstream_request_id. They record principal tags only on denied requests, so also put the approval id in the role session name. Other accounts: the module creates no RAM shares — share the service network or services yourself and add those roles to the invoker lists. The full model: Rehydration and audit.
Inputs
Outputs:
detect_endpoint, rehydrate_endpoint, lattice_client_security_group_id, detect_caller_policy, rehydrate_caller_policy, service_network_arn, detect_service_arn, rehydrate_service_arn, kms_key_arn, audit_bucket, vault_endpoint, detect_task_role_arn, rehydrate_task_role_arn, break_glass_role_arn, cluster_name, deployment_id. Rehydrate outputs are null without rehydration.
Gotchas
- A plan against a running install should be empty. The module declares the container-definition defaults ECS stores, so an unchanged apply doesn’t roll the services. If a plan replaces both task definitions without an input change, check your module version.
- Destroy stops on the audit bucket. It has
prevent_destroy— it’s an Object Lock record. For a trial:terraform state rm 'module.tenet_pii.aws_s3_bucket.audit[0]'(and its configuration resources) first, and inGOVERNANCEmode empty the bucket yourself. The KMS key is scheduled for deletion with a 30-day window. - Aurora with deletion protection fails
terraform destroyuntil you apply withaurora_deletion_protection = false.vault_final_snapshot = trueleaves<prefix>-vault-finalfor you to delete. - Destroy ordering is built in. The ASG depends on the VPC endpoints, their security-group rules and the instance role’s ECS attachment, so services and instances are removed while the ECS agent can still reach ECS. If a destroy still sticks, terminate the ASG’s instances, deregister them from the cluster, and run destroy again.
- A failed apply leaves resources in state; the next apply converges. Nothing is orphaned.
- The Aurora secret rotation and health-check notes on the CloudFormation page apply here too: tasks read
PGUSER/PGPASSWORDat start.