@@ -134,7 +134,30 @@ def __init__( # noqa: C901
134134 """Define stack."""
135135 super ().__init__ (scope , id , ** kwargs )
136136
137- vpc = ec2 .Vpc (self , f"{ id } -vpc" , nat_gateways = 0 )
137+ # vpc = ec2.Vpc(self, f"{id}-vpc", nat_gateways=0)
138+
139+ vpc = ec2 .Vpc (
140+ self ,
141+ f"{ id } -vpc" ,
142+ subnet_configuration = [
143+ ec2 .SubnetConfiguration (
144+ name = "ingress" ,
145+ cidr_mask = 24 ,
146+ subnet_type = ec2 .SubnetType .PUBLIC ,
147+ ),
148+ ec2 .SubnetConfiguration (
149+ name = "application" ,
150+ cidr_mask = 24 ,
151+ subnet_type = ec2 .SubnetType .PRIVATE_WITH_EGRESS ,
152+ ),
153+ ec2 .SubnetConfiguration (
154+ name = "rds" ,
155+ cidr_mask = 28 ,
156+ subnet_type = ec2 .SubnetType .PRIVATE_ISOLATED ,
157+ ),
158+ ],
159+ nat_gateways = 1 ,
160+ )
138161
139162 interface_endpoints = [
140163 (
@@ -163,6 +186,8 @@ def __init__( # noqa: C901
163186 ec2 .InstanceClass .BURSTABLE3 , ec2 .InstanceSize .SMALL
164187 ),
165188 database_name = "postgres" ,
189+ # should set the subnet to `PRIVATE_ISOLATED` but then we need either a bastion host to connect to the db
190+ # or an API to ingest/delete data in the DB
166191 vpc_subnets = ec2 .SubnetSelection (subnet_type = ec2 .SubnetType .PUBLIC ),
167192 backup_retention = Duration .days (7 ),
168193 deletion_protection = eoapi_settings .stage .lower () == "production" ,
@@ -229,6 +254,9 @@ def __init__( # noqa: C901
229254 platform = "linux/amd64" ,
230255 ),
231256 vpc = vpc ,
257+ vpc_subnets = ec2 .SubnetSelection (
258+ subnet_type = ec2 .SubnetType .PRIVATE_WITH_EGRESS
259+ ),
232260 allow_public_subnet = True ,
233261 handler = "handler.handler" ,
234262 memory_size = eoraster_settings .memory ,
@@ -250,6 +278,7 @@ def __init__( # noqa: C901
250278 )
251279
252280 db .connections .allow_from (eoraster_function , port_range = ec2 .Port .tcp (5432 ))
281+
253282 raster_api = apigw .HttpApi (
254283 self ,
255284 f"{ id } -raster-endpoint" ,
@@ -305,7 +334,6 @@ def __init__( # noqa: C901
305334 platform = "linux/amd64" ,
306335 ),
307336 vpc = vpc ,
308- allow_public_subnet = True ,
309337 handler = "handler.handler" ,
310338 memory_size = eostac_settings .memory ,
311339 timeout = Duration .seconds (eostac_settings .timeout ),
@@ -360,6 +388,8 @@ def __init__( # noqa: C901
360388
361389 if "DB_MAX_CONN_SIZE" not in env :
362390 env ["DB_MAX_CONN_SIZE" ] = "1"
391+ if "DB_MIN_CONN_SIZE" not in env :
392+ env ["DB_MIN_CONN_SIZE" ] = "1"
363393
364394 eovector_function = aws_lambda .Function (
365395 self ,
@@ -374,7 +404,6 @@ def __init__( # noqa: C901
374404 platform = "linux/amd64" ,
375405 ),
376406 vpc = vpc ,
377- allow_public_subnet = True ,
378407 handler = "handler.handler" ,
379408 memory_size = eovector_settings .memory ,
380409 timeout = Duration .seconds (eovector_settings .timeout ),
0 commit comments