File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ module "app" {
5959 services = each. value . services
6060 database_engine = try (each. value . database . type , null )
6161 database_version = try (each. value . database . version , null )
62+ internal = try (each. value . internal , true )
6263 domain = try (
6364 each. value . domain ,
6465 try (each. value . internal , true ) ? module. hosted_zones . route53_zone_name . internal : module. hosted_zones . route53_zone_name . external
Original file line number Diff line number Diff line change 11module "database" {
2- source = " ../database"
2+ source = " ../database"
33 for_each = var. database_engine != null ? toset ([" this" ]) : toset ([])
44
55 project = var. project
@@ -26,8 +26,8 @@ resource "aws_vpc_security_group_ingress_rule" "database" {
2626
2727locals {
2828 database_environment_variables = {
29- DATABASE_HOST = try (module. database [" this" ]. host , null )
30- DATABASE_PORT = try (module. database [" this" ]. port , null )
29+ DATABASE_HOST = try (module. database [" this" ]. host , null )
30+ DATABASE_PORT = try (module. database [" this" ]. port , null )
3131 }
3232 database_environment_secrets = {
3333 DATABASE_USERNAME = length (module. database ) > 0 ? " ${ module . database [" this" ]. secret_arn } :username" : null
Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ locals {
99 data. aws_cloudwatch_log_groups . ecs_insights . log_group_names ,
1010 data. aws_cloudwatch_log_groups . rds . log_group_names
1111 )
12+ oidc_settings = ! var. internal ? null : {
13+ client_secret_arn = module.secrets.secrets[" oidc" ].secret_arn
14+ authorization_endpoint = " https://codeforamerica.okta.com/oauth2/v1/authorize"
15+ issuer = " https://codeforamerica.okta.com"
16+ token_endpoint = " https://codeforamerica.okta.com/oauth2/v1/token"
17+ user_info_endpoint = " https://codeforamerica.okta.com/oauth2/v1/userinfo"
18+ }
1219 production = var. environment == " production"
1320 project_short = var. project_short != null ? var. project_short : var. project
1421 tags = {
Original file line number Diff line number Diff line change @@ -3,11 +3,27 @@ module "secrets" {
33
44 project = var. project
55 environment = var. environment
6+
7+ secrets = var. internal ? {
8+ " oidc" = {
9+ description = " OIDC secrets for ${ var . project } - ${ var . environment } "
10+ tags = local.tags
11+ # We need to set something here so that we can use the secret in the
12+ # OIDC settings for the service module.
13+ start_value = jsonencode ({
14+ " client_id" = " abc" ,
15+ " client_secret" = " 123" ,
16+ })
17+ }
18+ } : {}
619}
720
821module "service" {
9- source = " github.com/codeforamerica/tofu-modules-aws-fargate-service?ref=1.3 .0"
22+ source = " github.com/codeforamerica/tofu-modules-aws-fargate-service?ref=1.4 .0"
1023 for_each = var. services
24+ depends_on = [
25+ module . secrets
26+ ]
1127
1228 project = var. project
1329 project_short = local. project_short
@@ -20,6 +36,8 @@ module "service" {
2036
2137 domain = var. domain
2238 subdomain = " ${ try (each. value . subdomain , " www" )} ${ local . domain_prefix } "
39+ force_delete = ! local. production
40+ oidc_settings = local. oidc_settings
2341
2442 vpc_id = var. vpc_id
2543 private_subnets = var. private_subnets
Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ variable "environment" {
2020 type = string
2121}
2222
23+ variable "internal" {
24+ description = " Whether this application is internal, meaning it should only be accessible to staff via an OIDC connection."
25+ type = bool
26+ default = true
27+ }
28+
2329variable "logging_key_arn" {
2430 description = " The ARN of the KMS key used for logging."
2531 type = string
You can’t perform that action at this time.
0 commit comments