2443909362
---ci--- project: nova-platform milestone: v1.0 status: complete requirements: covered: [REQ-01,REQ-02,REQ-03,REQ-04,REQ-05,REQ-06,REQ-07,REQ-08,REQ-09,REQ-10,REQ-11,REQ-12,REQ-13,REQ-14,REQ-15,REQ-16,REQ-17,REQ-18,REQ-19,REQ-20,REQ-21,REQ-22,REQ-23,REQ-24,REQ-25,REQ-26,REQ-27,REQ-28,REQ-29,REQ-30,REQ-31,REQ-32,REQ-33,REQ-34,REQ-35,REQ-36,REQ-37,REQ-38] partial: [] ---/ci--- v1.0 milestone complete: simplified infrastructure-delivery platform derived from Nova (acdl). 6 phases (P0-P5 + P6 final). 38 REQ-IDs. 38 decisions (D-001..D-038). 76 tests pass. Engine boundary holds. Happy paths green (check-only + CI). 13 L1 + 2 L2 modules. 5 terraform roots. Shell reproducibility. Zero OOS files. Tags: v0.1.0 (P0) → v0.1.1..v0.1.5 (P1..P5) → v0.1.6 (P6 = milestone release on v0.1 patch line).
114 lines
3.6 KiB
Terraform
114 lines
3.6 KiB
Terraform
# Nova sample consumer root — instantiates the L2 microservice pattern.
|
|
#
|
|
# This is a sample consumer terraform root. It instantiates the L2
|
|
# `microservice` module (modules/l2/microservice/terraform), which
|
|
# internally composes six L1 primitives (vpc + ecs-cluster + ecs-service +
|
|
# iam-role + ecr + alb per D-038) via its own module blocks. The L2 is
|
|
# opaque at the stack level (D-012): the consumer root sees ONE module,
|
|
# not the individual L1 children.
|
|
#
|
|
# The platform VPC is referenced via terraform_remote_state (data source)
|
|
# so the microservice does not create its own VPC — it reuses the shared
|
|
# platform VPC from terraform/platform/main.tf.
|
|
#
|
|
# State: spike/microservice/<env>/terraform.tfstate (separate from platform/).
|
|
|
|
terraform {
|
|
required_version = ">= 1.9, < 1.10"
|
|
required_providers {
|
|
aws = {
|
|
source = "hashicorp/aws"
|
|
version = "~> 5.0"
|
|
}
|
|
}
|
|
# Partial backend config — the bucket name is supplied at `terraform init`
|
|
# time via `-backend-config=bucket=...` (the bucket is created by
|
|
# terraform/bootstrap/create_state_backend.py as nova-tfstate-<account>-<region>).
|
|
backend "s3" {
|
|
key = "spike/microservice/dev/terraform.tfstate"
|
|
region = "us-east-1"
|
|
}
|
|
}
|
|
|
|
provider "aws" {
|
|
region = "us-east-1"
|
|
}
|
|
|
|
variable "service_name" {
|
|
description = "Name of the ECS microservice."
|
|
type = string
|
|
default = "nova-sample-app"
|
|
}
|
|
|
|
variable "container_image" {
|
|
description = "Container image to deploy (ECR URL)."
|
|
type = string
|
|
}
|
|
|
|
variable "desired_count" {
|
|
description = "Number of ECS Fargate tasks to run."
|
|
type = number
|
|
default = 1
|
|
}
|
|
|
|
variable "container_port" {
|
|
description = "Container port the service listens on."
|
|
type = number
|
|
default = 80
|
|
}
|
|
|
|
variable "platform_state_bucket" {
|
|
description = "S3 bucket holding the platform VPC state (nova-tfstate-<account>-<region>)."
|
|
type = string
|
|
}
|
|
|
|
variable "platform_state_key" {
|
|
description = "S3 key for the platform VPC state (default platform/terraform.tfstate)."
|
|
type = string
|
|
default = "platform/terraform.tfstate"
|
|
}
|
|
|
|
variable "platform_state_region" {
|
|
description = "Region of the platform state bucket."
|
|
type = string
|
|
default = "us-east-1"
|
|
}
|
|
|
|
# Reference the shared platform VPC via terraform_remote_state. The L2
|
|
# microservice module consumes these outputs to wire the ALB + ECS service
|
|
# into the platform subnets / security group (no per-contract VPC).
|
|
data "terraform_remote_state" "platform" {
|
|
backend = "s3"
|
|
config = {
|
|
bucket = var.platform_state_bucket
|
|
key = var.platform_state_key
|
|
region = var.platform_state_region
|
|
}
|
|
}
|
|
|
|
# The L2 microservice pattern — opaque at this level (D-012). Internally
|
|
# composes vpc + ecs-cluster + ecs-service + iam-role + ecr + alb (D-038).
|
|
module "microservice" {
|
|
source = "../modules/l2/microservice/terraform"
|
|
|
|
service_name = var.service_name
|
|
desired_count = var.desired_count
|
|
container_image = var.container_image
|
|
container_port = var.container_port
|
|
|
|
# The L2 module reads the platform VPC outputs from this data source
|
|
# (subnets, security group) via its own internal wiring — the L2
|
|
# interface is intentionally simplified (D-012/D-013).
|
|
platform_subnet_ids = split(",", data.terraform_remote_state.platform.outputs.subnet_ids)
|
|
platform_security_group_id = data.terraform_remote_state.platform.outputs.ecs_security_group_id
|
|
}
|
|
|
|
output "service_arn" {
|
|
description = "The ARN of the deployed ECS service."
|
|
value = module.microservice.service_arn
|
|
}
|
|
|
|
output "lb_dns_name" {
|
|
description = "The DNS name of the fronting Application Load Balancer."
|
|
value = module.microservice.lb_dns_name
|
|
} |