0e6ecae26d
Rename all acdl-* AWS resources → nova-* across terraform (DynamoDB, Secrets Manager, Lambda, SNS, SG, KMS alias, ECS, ECR, IAM user/policy, state bucket, ALB, VPC/subnet names). Lambda default table names → nova-* (D-111). State bucket backend → nova-tfstate (-migrate-state documented). New docs/NOVA_AWS_MIGRATION.md runbook (staged migration + rollback). New scripts/migrate_dynamodb_data.py (scan+copy, dry-run default). acdl-deploy- → nova-deploy- role ARN in deploy workflows. Test fixtures updated; terraform validate + pytest + run_ci.sh PASS. ---ci--- project: acdl phase: 4 milestone: v1.15 status: execute ---/ci---
147 lines
3.5 KiB
Terraform
147 lines
3.5 KiB
Terraform
resource "aws_vpc" "vpc-vpc" {
|
|
cidr_block = "10.0.0.0/16"
|
|
tags = {
|
|
Name = "nova-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 = "nova-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 = "nova-microservice-rt"
|
|
}
|
|
}
|
|
|
|
resource "aws_ecs_cluster" "cluster" {
|
|
name = "nova-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 = "nova-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 = "nova-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 = "nova-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 = "nova-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/nova-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 = "nova-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 = "nova-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
|
|
} |