Skip to content

Commit f2b012d

Browse files
committed
feat: Added a module for applications.
1 parent 3e3b290 commit f2b012d

9 files changed

Lines changed: 135 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
title: Washington, D.C. Sun Bucks (Summer EBT) Self-Service Portal
2+
name: sebt-portal
3+
program: safety-net
4+
repo: codeforamerica/cfa-dc-sebt-portal
5+
database:
6+
type: mssql
7+
services:
8+
web:
9+
dockerfile: ./src/DC.SEBT.Web/Dockerfile
10+
context: ./src
11+
expose: 8080
12+
public: true
13+
ports:
14+
- 8080
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
locals {
2+
apps = {
3+
sebt : yamldecode(file("${path.module}/apps/dc-sebt-portal.yaml"))
4+
}
5+
}

tofu/config/development/infra/main.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,21 @@ module "vpc" {
4747
# 10.1.8.1 - 10.1.19.254
4848
public_subnets = ["10.1.8.0/22", "10.1.12.0/22", "10.1.16.0/22"]
4949
}
50+
51+
module "app" {
52+
source = "../../../modules/app"
53+
54+
project = local.apps["sebt"].name
55+
environment = "development"
56+
program = local.apps["sebt"].program
57+
services = local.apps["sebt"].services
58+
domain = try(
59+
local.apps["sebt"].domain,
60+
try(local.apps.internal, true) ? module.hosted_zones.route53_zone_name.internal : module.hosted_zones.route53_zone_name.external
61+
)
62+
63+
logging_key_arn = module.logging.kms_key_arn
64+
vpc_id = module.vpc.vpc_id
65+
private_subnets = module.vpc.private_subnets
66+
public_subnets = module.vpc.public_subnets
67+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "apps" {
2+
description = "Deployed applications."
3+
value = module.app.services
4+
}

tofu/modules/app/local.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
locals {
2+
project_short = var.project_short != null ? var.project_short : var.project
3+
}

tofu/modules/app/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module "service" {
2+
source = "github.com/codeforamerica/tofu-modules-aws-fargate-service?ref=1.2.1"
3+
for_each = var.services
4+
5+
project = var.project
6+
project_short = local.project_short
7+
environment = var.environment
8+
public = try(each.value.public, false)
9+
service = each.key
10+
service_short = try(each.value.short_name, each.key)
11+
12+
domain = var.domain
13+
subdomain = try(each.value.subdomain, "www")
14+
15+
vpc_id = var.vpc_id
16+
private_subnets = var.private_subnets
17+
public_subnets = var.public_subnets
18+
logging_key_id = var.logging_key_arn
19+
container_port = try(each.value.expose, 3000)
20+
create_version_parameter = true
21+
22+
tags = {
23+
application = "${var.project}-${var.environment}"
24+
program = var.program
25+
}
26+
}

tofu/modules/app/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "services" {
2+
description = "Deployed services for the application."
3+
value = module.service
4+
}

tofu/modules/app/variables.tf

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
variable "domain" {
2+
description = "The domain for the application."
3+
type = string
4+
}
5+
6+
variable "environment" {
7+
description = "The environment for the application."
8+
type = string
9+
}
10+
11+
variable "logging_key_arn" {
12+
description = "The ARN of the KMS key used for logging."
13+
type = string
14+
}
15+
16+
variable "private_subnets" {
17+
description = "List of private subnets for the application."
18+
type = list(string)
19+
}
20+
21+
variable "program" {
22+
description = "The program the application is associated with."
23+
type = string
24+
}
25+
26+
variable "project" {
27+
description = "The name of the project."
28+
type = string
29+
}
30+
31+
variable "project_short" {
32+
description = "Short name for the project, used in resource names."
33+
type = string
34+
default = null
35+
}
36+
37+
variable "public_subnets" {
38+
description = "List of public subnets for the application."
39+
type = list(string)
40+
}
41+
42+
variable "services" {
43+
description = "Services to deploy for the application."
44+
type = map(any)
45+
default = {}
46+
}
47+
48+
variable "vpc_id" {
49+
description = "The VPC ID where the application will be deployed."
50+
type = string
51+
}

tofu/modules/app/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.9"
3+
4+
required_providers {
5+
aws = {
6+
version = "~> 5.93"
7+
source = "hashicorp/aws"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)