File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ module "app" {
5353 for_each = local. apps
5454
5555 project = each. value . name
56+ project_short = try (each. value . name_short , each. value . name )
5657 environment = " development"
5758 program = each. value . program
5859 services = each. value . services
Original file line number Diff line number Diff line change 11module "database" {
22 source = " ../database"
3+ for_each = var. database_engine != null ? toset ([" this" ]) : toset ([])
34
45 project = var. project
56 environment = var. environment
@@ -14,11 +15,22 @@ module "database" {
1415}
1516
1617resource "aws_vpc_security_group_ingress_rule" "database" {
17- for_each = module. service
18- security_group_id = module. database . security_group_id
18+ for_each = length ( module. database ) > 0 ? module . service : {}
19+ security_group_id = module. database [ " this " ] . security_group_id
1920
2021 ip_protocol = " tcp"
21- from_port = module. database . port
22- to_port = module. database . port
22+ from_port = module. database [ " this " ] . port
23+ to_port = module. database [ " this " ] . port
2324 referenced_security_group_id = each. value . security_group_id
2425}
26+
27+ locals {
28+ database_environment_variables = {
29+ DATABASE_HOST = try (module. database [" this" ]. host , null )
30+ DATABASE_PORT = try (module. database [" this" ]. port , null )
31+ }
32+ database_environment_secrets = {
33+ DATABASE_USERNAME = length (module. database ) > 0 ? " ${ module . database [" this" ]. secret_arn } :username" : null
34+ DATABASE_PASSWORD = length (module. database ) > 0 ? " ${ module . database [" this" ]. secret_arn } :password" : null
35+ }
36+ }
Original file line number Diff line number Diff line change @@ -28,15 +28,13 @@ module "service" {
2828 container_port = try (each. value . expose , 3000 )
2929 create_version_parameter = true
3030
31- environment_variables = {
32- DATABASE_HOST = module.database.host
33- DATABASE_PORT = module.database.port
34- }
35-
36- environment_secrets = {
37- DATABASE_USERNAME = " ${ module . database . secret_arn } :username"
38- DATABASE_PASSWORD = " ${ module . database . secret_arn } :password"
39- }
31+ environment_variables = tomap ({
32+ for k , v in local . database_environment_variables : k => v if v != " " && v != null
33+ })
34+
35+ environment_secrets = tomap ({
36+ for k , v in local . database_environment_secrets : k => v if v != " " && v != null
37+ })
4038
4139 tags = local. tags
4240}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments