Implement reversible PII de-identification round trip (T1–T7)

Build the AWS side of the HNCB demo end to end (region ap-southeast-1):

- T1 /tokenize + T2 /restore: Lambdas behind a public API Gateway (shared-secret
  auth), Presidio detection, random per-request tokens, DynamoDB vault; overlap
  resolution so a ROC ID stays TW_ROC_ID.
- T3: Presidio made private (SG-locked to the tokenize Lambda in-VPC; DynamoDB
  gateway endpoint); only /tokenize + /restore are public.
- T4: RAG Lambda registered as an MCP tool on an AgentCore Gateway (AWS_IAM/SigV4);
  agentcore_setup.sh + a SigV4 MCP invoke test.
- T5: Strands agent deployed to AgentCore Runtime; SigV4 gateway auth, apac
  inference profile, pinned deps.
- T6: advisor UI on S3+CloudFront with a Fusion-less demo orchestrator (/demo)
  chaining tokenize -> runtime -> restore.
- T7: README runbook + trace check; teardown deletes gateway/runtime/memory/ECR.

Verified live: the cloud AgentCore/Bedrock trace shows only tokens, never the
real name. Secrets stay in gitignored local.auto.tfvars.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 17:10:58 +10:00
parent 6b2a051be3
commit 78d67a2469
21 changed files with 1439 additions and 107 deletions

View File

@@ -6,14 +6,47 @@ cd "$(dirname "$0")/.."
REGION="${REGION:-us-east-1}"
echo "==> Delete AgentCore resources (adjust names to what agentcore_setup created)"
echo " agentcore runtime delete --name hncb-advisor-agent --region ${REGION} || true"
echo " agentcore gateway delete --name hncb-rag-gateway --region ${REGION} || true"
echo "==> Delete AgentCore Gateway + targets (not in Terraform state)"
export AWS_PAGER=""
GW_ID="$(aws bedrock-agentcore-control list-gateways --region "$REGION" \
--query "items[?name=='hncb-rag-gateway'].gatewayId | [0]" --output text 2>/dev/null || echo None)"
if [ "$GW_ID" != "None" ] && [ -n "$GW_ID" ]; then
for TID in $(aws bedrock-agentcore-control list-gateway-targets --region "$REGION" \
--gateway-identifier "$GW_ID" --query 'items[].targetId' --output text 2>/dev/null); do
aws bedrock-agentcore-control delete-gateway-target --region "$REGION" \
--gateway-identifier "$GW_ID" --target-id "$TID" || true
done
aws bedrock-agentcore-control delete-gateway --region "$REGION" --gateway-identifier "$GW_ID" || true
echo " deleted gateway $GW_ID"
fi
echo "==> Delete AgentCore Runtime + Memory (T5; not in Terraform state)"
for RT in $(aws bedrock-agentcore-control list-agent-runtimes --region "$REGION" \
--query "agentRuntimes[?starts_with(agentRuntimeName,'hncb')].agentRuntimeId" --output text 2>/dev/null); do
aws bedrock-agentcore-control delete-agent-runtime --region "$REGION" --agent-runtime-id "$RT" || true
echo " deleted runtime $RT"
done
for MEM in $(aws bedrock-agentcore-control list-memories --region "$REGION" \
--query "memories[?starts_with(id,'hncb')].id" --output text 2>/dev/null); do
aws bedrock-agentcore-control delete-memory --region "$REGION" --memory-id "$MEM" || true
echo " deleted memory $MEM"
done
echo " (agentcore launch also auto-created an ECR repo, a CodeBuild project, and an"
echo " AmazonBedrockAgentCoreSDKRuntime-* execution role -- delete by hand if desired.)"
echo "==> Terraform destroy (DynamoDB, Lambda, ECS, IAM)"
terraform -chdir=terraform destroy -auto-approve
echo "==> (optional) delete the Presidio ECR repo"
echo " aws ecr delete-repository --repository-name hncb-presidio --force --region ${REGION} || true"
echo "==> Delete ECR repos (Presidio + the agentcore-built agent image; not in TF state)"
for REPO in hncb-presidio bedrock-agentcore-hncb_advisor_agent; do
aws ecr delete-repository --repository-name "$REPO" --force --region "$REGION" 2>/dev/null \
&& echo " deleted ECR $REPO" || true
done
echo " (also free/leftover: the AmazonBedrockAgentCoreSDKRuntime-* role and a CodeBuild"
echo " project agentcore created -- no cost idle; delete by hand if you want it spotless.)"
echo "Teardown complete (mind any S3/CloudFront you created for the UI)."
echo "==> (manual) default VPC created by hand for the T1 live deploy (ap-southeast-1)"
echo " Not in Terraform state; tagged maintenance=manual-cleanup-required. Free while"
echo " empty, so usually leave it. To remove: aws ec2 delete-vpc --vpc-id vpc-0e97f4fdb643c3e26"
echo "Teardown complete. (UI S3+CloudFront are Terraform-managed now, so the destroy"
echo " above removes them; the S3 bucket has force_destroy=true.)"