Skip to main content
The CloudFormation template (tenet-pii-enterprise.yaml): one stack → a customer-managed KMS key, an Aurora PostgreSQL Serverless v2 vault, the VPC endpoints, an ECS cluster on c9g.xlarge, and the detect and rehydrate services, each behind its own Amazon VPC Lattice service whose IAM auth policy names your caller roles per route.

When to use it

You want ECS rather than EKS, and you want everything created and wired for you. It deploys into an existing VPC with private subnets and no NAT. Use the Terraform module for the same shape in Terraform.

Deploy the CloudFormation stack — collects parameters, runs preflight checks, and stops for approval before creating anything.

Open in Cursor

What it creates

Deploy

Download the template:
Before you deploy: subscribe and verify the release, use a VPC with DNS hostnames and DNS support enabled (the interface endpoints’ private DNS needs both), and check your On-Demand Standard vCPU quota — each detect task fills a c9g.xlarge, so the default stack needs 8 vCPUs, 12 with rehydration. ImageUri is the Marketplace image from the release record, by digest, in every Region — don’t copy it. Outside us-east-1 the stack creates cross-Region endpoints to reach it, so the role that runs the stack needs vpce:AllowMultiRegion; Administrator and PowerUser roles already have it (The image in every Region). The template is over CloudFormation’s inline size limit, so $TEMPLATE_BUCKET must be an S3 bucket you own in the deployment Region. Run the deploy as KeyAdminRoleArn — while the stack builds Aurora and its secret, that role needs CreateGrant and data-key access through RDS and Secrets Manager, which the key policy grants only via kms:ViaService.
  • CAPABILITY_AUTO_EXPAND is required. The template uses the AWS::LanguageExtensions transform (so VaultDeletionPolicy can set the Aurora cluster’s DeletionPolicy). Without it the deploy fails before creating anything.
  • Trial stack you’ll delete: add AuroraDeletionProtection=false VaultDeletionPolicy=Delete AuditObjectLockMode=GOVERNANCE.
  • Detection only: EnableRehydration=false. No rehydrate service, task or execution role, or Lattice service is created. The audit bucket still is — detect audits erasures.

Callers

Each workload that calls the services needs four things:
  1. Its IAM role in the right list: DetectInvokerRoleArns (POST /detect, /redact, /deidentify), ErasureInvokerRoleArns (DELETE /sessions/{session_id}) or RehydrateInvokerRoleArns (POST /reidentify). The auth policies name exactly these roles, per path and method. Entries must be IAM role ARNs; the runtime refuses users, root and wildcards at startup.
  2. The DetectCallerPolicy or RehydrateCallerPolicy output attached to that role as an identity policy (vpc-lattice-svcs:Invoke on the service). A same-account caller needs both this and the auth policy; either alone is a 403.
  3. A network path: attach the LatticeClientSecurityGroupId output to the workload, or allow egress tcp/443 to the com.amazonaws.<region>.vpc-lattice prefix list.
  4. Signed requests: SigV4, service vpc-lattice-svcs, the stack’s Region, header x-amz-content-sha256: UNSIGNED-PAYLOAD, over HTTPS to DetectEndpoint or RehydrateEndpoint. The tenet-pii-lattice client does this (pip install https://platform.tenetlabs.com/enterprise/current/tenet_pii_lattice.tar.gz; Python 3.11+, boto3); plain botocore SigV4Auth works too. Reuse connections — each new connection pays a TLS handshake.
With RequireRehydrateApprovalTag=true, a reidentify call must come from a role session tagged tenet-approval-id; your approval workflow sets it when it assumes the invoker role, and Lattice checks it on every call. Also put the approval id in the RoleSessionName: Lattice access logs record principal tags only on denied requests, while every audit record carries the caller’s role session ARN. requestId in /<NamePrefix>/lattice matches upstream_request_id in the audit record. Callers in another VPC need that VPC associated with the service network (ServiceNetworkArn output) and listed in AllowedSourceVpcIds. Callers in another account need the service network or the services shared with AWS RAM, and their roles listed by ARN. The full model: Rehydration and audit.

Outputs

Parameters

The detect egress rule is tcp/443 to 0.0.0.0/0 through the NAT, not limited to Tenet’s endpoint — a compromised detect task could reach any HTTPS host. For tighter control, put AWS Network Firewall with a domain allowlist or an egress proxy on that path. Record contents: Monitoring.

Bringing your own KMS key

With KmsKeyArn set, the template can’t edit that key’s policy. Add these statements yourself — the log-group one before the first deploy (or the log groups fail to create), the rest once the stack has created the roles (<prefix>-detect-task, <prefix>-rehydrate-task, <prefix>-detect-exec, <prefix>-rehydrate-exec):
  • The two Deny statements keep detect out of the vault. Detect creates each vault key pair and wraps its private half, but can never unwrap it, so it can’t read back any value it stored. The stack’s detect role policy repeats both Denies, so they hold before you edit the key policy; keep them in the key policy anyway, so no IAM policy attached to the role later can lift them. Architecture — KMS design.
  • DetectErasureAuditWritesViaS3 lets detect write erasure records to the SSE-KMS audit bucket.
  • If your key policy delegates to IAM (the root statement), add the log-group statement before the first deploy.

Gotchas

  • The Aurora master secret rotates every 7 days. ECS injects PGUSER/PGPASSWORD at task start, so running tasks keep the old password and fail on their next reconnect. After each rotation, aws ecs update-service --force-new-deployment both services — or create a dedicated least-privilege database user for the engine with its own rotation schedule (recommended).
  • Stack updates reset the detect count. With autoscaling on, every update sets the service back to DetectDesiredCount, then autoscaling scales it up again. Update off-peak or raise DetectDesiredCount first.
  • Health checks. Detect’s container check runs tenet-pii-enterprise healthcheck against /healthz; its Lattice target group checks /readyz. Rehydrate’s container check uses --ready (/readyz), so a task that can’t reach the vault is replaced; its target group checks /readyz too. The probes aren’t routed through Lattice — callers get 404 on them.
  • VPC Lattice isn’t in every AZ (for example use1-az3 in us-east-1). Keep PrivateSubnetIds in supported AZs, or target registration fails for tasks placed there.
  • One service network per VPC. If VpcId is already associated with one, pass ExistingServiceNetworkArn. The stack then only adds its services; you own that network’s VPC associations and auth policy. The services’ own auth policies still apply.
  • Rollouts replace tasks in place. 50/100 stops half the tasks, starts the new revision on the freed instances, then does the other half — during a rollout, 1 of 2 detect tasks serves. Deploy off-peak or raise DetectDesiredCount first; or set 100/200 and leave AsgMaxSize headroom for one surge instance per service.
  • Failed first create. The KMS key and audit bucket use DeletionPolicy: RetainExceptOnCreate, so a rollback deletes them (the key enters a 30-day pending deletion). With AuroraDeletionProtection=true, a failed create ends in ROLLBACK_FAILED — disable protection on the cluster and continue the rollback.
  • “Invalid principals” on VaultKey. IAM propagation can lag a role created seconds earlier. Retry the stack operation.
  • Tear-down. Stack delete keeps the KMS key and the audit bucket (in COMPLIANCE mode nobody can delete audit objects before retention ends). Set AuroraDeletionProtection=false and update before deleting; VaultDeletionPolicy=Snapshot leaves a final snapshot for you to delete. A delete can end DELETE_FAILED on a Lattice target group with “Exceeded attempts to wait”, because ECS is still deregistering tasks — delete the stack again. If a delete sticks with services in DRAINING, see Troubleshooting.
  • One private subnet per AZ. Interface endpoints take at most one subnet per AZ.
  • Tasks stop at startup with a metering error. AWS Marketplace metering refused this deployment means the account isn’t subscribed or the task role lacks aws-marketplace:MeterUsage; AWS Marketplace metering is unreachable means the metering-marketplace endpoint is missing or unreachable. With CreateVpcEndpoints=false, your existing endpoints must include metering-marketplace. Troubleshooting.