699aa542df
---ci---
project: acdl
phase: 15
milestone: v1.2
status: verify
verdict: PARTIAL
requirements:
covered: [REQ-34]
partial: [REQ-33]
blocker:
- id: P0-IAM
description: terraform apply fails with AccessDenied on ECS/ECR/IAM/EC2 — live spike_runner_policy.json not pushed (root key deactivated per D-034)
unblock: operator runs create_iam_user.py with root/admin creds to push the expanded policy, then terraform apply succeeds (plan valid, 13 to add)
---/ci---
Phase 15 plan-as-execute + verify. PARTIAL: terraform apply blocked by IAM.
- Consumer microservice content authored (app.py + Dockerfile + README.md).
- Docker image acdl-microservice:latest built.
- Adapter fixed: ref emission (bare), JSON-string jsonencode, ECS service
network_configuration/load_balancer/desired_count/launch_type/task_definition,
listener default_action/load_balancer_arn, target group target_type/vpc_id/protocol,
VPC tags (not name), IGW + route table association, managed_policy_arns list.
- L1 fixes: l1-ecs-service (removed port from service sub-resource),
l1-vpc (added intra_refs, removed igw_id output).
- Resolver: intra_refs resolution (refs between sub-resources of same L1).
- terraform validate + plan succeed (13 to add).
- terraform apply BLOCKED (AccessDenied — live IAM policy not updated).
- Evidence event TERRAFORM_APPLY_BLOCKED written to DynamoDB outbox.
- v1.1 S3 regression: byte-identical.
Ready to ship v1.2.5 (partial).
148 lines
3.3 KiB
Terraform
148 lines
3.3 KiB
Terraform
resource "aws_vpc" "vpc-vpc" {
|
|
cidr_block = "10.0.0.0/16"
|
|
tags = {
|
|
Name = "acdl-microservice"
|
|
}
|
|
}
|
|
|
|
output "vpc_id" {
|
|
value = aws_vpc.vpc-vpc.id
|
|
}
|
|
|
|
resource "aws_subnet" "vpc-subnet" {
|
|
cidr_block = "10.0.0.0/16"
|
|
vpc_id = aws_vpc.vpc-vpc.id
|
|
tags = {
|
|
Name = "acdl-microservice"
|
|
}
|
|
}
|
|
|
|
resource "aws_route_table" "vpc-routetable" {
|
|
vpc_id = aws_vpc.vpc-vpc.id
|
|
route {
|
|
cidr_block = "0.0.0.0/0"
|
|
gateway_id = aws_internet_gateway.vpc-igw.id
|
|
}
|
|
tags = {
|
|
Name = "acdl-microservice-rt"
|
|
}
|
|
}
|
|
|
|
resource "aws_ecs_cluster" "cluster" {
|
|
name = "acdl-microservice"
|
|
}
|
|
|
|
output "cluster_arn" {
|
|
value = aws_ecs_cluster.cluster.arn
|
|
}
|
|
|
|
output "cluster_id" {
|
|
value = aws_ecs_cluster.cluster.id
|
|
}
|
|
|
|
resource "aws_ecr_repository" "ecr" {
|
|
name = "acdl-microservice"
|
|
}
|
|
|
|
output "repository_url" {
|
|
value = aws_ecr_repository.ecr.repository_url
|
|
}
|
|
|
|
output "repository_arn" {
|
|
value = aws_ecr_repository.ecr.arn
|
|
}
|
|
|
|
resource "aws_iam_role" "roles" {
|
|
name = "acdl-microservice-exec"
|
|
assume_role_policy = jsonencode({"Statement": [{"Action": "sts:AssumeRole", "Effect": "Allow", "Principal": {"Service": "ecs-tasks.amazonaws.com"}}], "Version": "2012-10-17"})
|
|
managed_policy_arns = ["arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"]
|
|
}
|
|
|
|
output "role_arn" {
|
|
value = aws_iam_role.roles.arn
|
|
}
|
|
|
|
output "role_id" {
|
|
value = aws_iam_role.roles.id
|
|
}
|
|
|
|
resource "aws_lb" "alb-loadbalancer" {
|
|
name = "acdl-microservice"
|
|
subnets = [aws_subnet.vpc-subnet.id]
|
|
security_groups = [aws_iam_role.roles.arn]
|
|
load_balancer_type = "application"
|
|
}
|
|
|
|
output "lb_arn" {
|
|
value = aws_lb.alb-loadbalancer.id
|
|
}
|
|
|
|
resource "aws_lb_target_group" "alb-targetgroup" {
|
|
name = "acdl-microservice"
|
|
port = 8080
|
|
target_type = "ip"
|
|
vpc_id = aws_vpc.vpc-vpc.id
|
|
protocol = "HTTP"
|
|
}
|
|
|
|
output "target_group_arn" {
|
|
value = aws_lb_target_group.alb-targetgroup.arn
|
|
}
|
|
|
|
resource "aws_lb_listener" "alb-listener" {
|
|
port = 8080
|
|
default_action {
|
|
type = "forward"
|
|
target_group_arn = aws_lb_target_group.alb-targetgroup.arn
|
|
}
|
|
load_balancer_arn = aws_lb.alb-loadbalancer.id
|
|
}
|
|
|
|
output "listener_arn" {
|
|
value = aws_lb_listener.alb-listener.id
|
|
}
|
|
|
|
resource "aws_ecs_task_definition" "service-taskdefinition" {
|
|
cpu = 256
|
|
memory = 512
|
|
container_definitions = jsonencode([{"essential": true, "image": "581513795199.dkr.ecr.us-east-1.amazonaws.com/acdl-microservice:latest", "name": "app", "portMappings": [{"containerPort": 8080}]}])
|
|
family = "app"
|
|
}
|
|
|
|
output "task_def_arn" {
|
|
value = aws_ecs_task_definition.service-taskdefinition.arn
|
|
}
|
|
|
|
resource "aws_ecs_service" "service-service" {
|
|
cluster = aws_ecs_cluster.cluster.arn
|
|
load_balancer {
|
|
target_group_arn = aws_lb_target_group.alb-targetgroup.arn
|
|
container_name = "app"
|
|
container_port = 8080
|
|
}
|
|
network_configuration {
|
|
subnets = [aws_subnet.vpc-subnet.id]
|
|
security_groups = [aws_iam_role.roles.arn]
|
|
}
|
|
desired_count = 1
|
|
launch_type = "FARGATE"
|
|
task_definition = aws_ecs_task_definition.service-taskdefinition.arn
|
|
name = "acdl-microservice"
|
|
}
|
|
|
|
output "service_arn" {
|
|
value = aws_ecs_service.service-service.id
|
|
}
|
|
|
|
resource "aws_internet_gateway" "vpc-igw" {
|
|
vpc_id = aws_vpc.vpc-vpc.id
|
|
tags = {
|
|
Name = "acdl-microservice-igw"
|
|
}
|
|
}
|
|
|
|
resource "aws_route_table_association" "vpc-rta" {
|
|
subnet_id = aws_subnet.vpc-subnet.id
|
|
route_table_id = aws_route_table.vpc-routetable.id
|
|
}
|