# --------------------------------------------------------------------------- # Hosting for the Presidio detector only. Fusion is a shared SaaS instance and is # NOT deployed here. Because Fusion SaaS calls the detector over the internet, the # analyzer port is public in this demo (lock it down / add auth for anything real; # better: fold detection behind the /tokenize endpoint so only that is public -- # see CLAUDE.md task T3). # # For a laptop-only rehearsal you can skip this file and run Presidio via docker. # --------------------------------------------------------------------------- data "aws_vpc" "default" { default = true } data "aws_subnets" "default" { filter { name = "vpc-id" values = [data.aws_vpc.default.id] } } resource "aws_ecs_cluster" "this" { name = "${local.name}-cluster" tags = local.onprem_tag } resource "aws_security_group" "svc" { name = "${local.name}-svc-sg" description = "Demo services SG" vpc_id = data.aws_vpc.default.id ingress { description = "Presidio analyzer (public for SaaS Fusion demo - restrict for real use)" from_port = 5001 to_port = 5001 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } tags = local.onprem_tag } resource "aws_iam_role" "ecs_exec" { name = "${local.name}-ecs-exec" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Principal = { Service = "ecs-tasks.amazonaws.com" } Action = "sts:AssumeRole" }] }) } resource "aws_iam_role_policy_attachment" "ecs_exec" { role = aws_iam_role.ecs_exec.name policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy" } resource "aws_ecs_task_definition" "presidio" { family = "${local.name}-presidio" requires_compatibilities = ["FARGATE"] network_mode = "awsvpc" cpu = 512 memory = 1024 execution_role_arn = aws_iam_role.ecs_exec.arn container_definitions = jsonencode([{ name = "presidio" image = var.presidio_image_uri essential = true portMappings = [{ containerPort = 5001 }] }]) tags = local.onprem_tag } resource "aws_ecs_service" "presidio" { name = "${local.name}-presidio" cluster = aws_ecs_cluster.this.id task_definition = aws_ecs_task_definition.presidio.arn desired_count = 1 launch_type = "FARGATE" network_configuration { subnets = data.aws_subnets.default.ids security_groups = [aws_security_group.svc.id] assign_public_ip = true } tags = local.onprem_tag }