Skip to content

Commit dd93c71

Browse files
committed
make bastion host optional and avoid rewriting all the params in app wrapper just use the config as kwargs
1 parent 2a036cf commit dd93c71

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

app.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,17 @@
1818
config = Config()
1919

2020
vpc_stack = vpc.VpcStack(
21-
tags=config.tags,
22-
scope=app,
23-
id=config.build_service_name("pgSTAC-vpc"),
24-
nat_gateway_count=config.nat_gateway_count,
21+
tags=config.tags, scope=app, id=config.build_service_name("pgSTAC-vpc"), **config
2522
)
2623

27-
2824
pgstac_infra_stack = pgStacInfra.pgStacInfraStack(
2925
scope=app,
30-
tags=config.tags,
3126
id=config.build_service_name("pgSTAC-infra"),
3227
vpc=vpc_stack.vpc,
3328
stac_api_lambda_name=config.build_service_name("STAC API"),
3429
titiler_pgstac_api_lambda_name=config.build_service_name("titiler pgSTAC API"),
3530
tipg_api_lambda_name=config.build_service_name("tipg API"),
36-
stage=config.stage,
37-
db_allocated_storage=config.db_allocated_storage,
38-
public_db_subnet=config.public_db_subnet,
39-
db_instance_type=config.db_instance_type,
40-
bastion_host_allow_ip_list=config.bastion_host_allow_ip_list,
41-
bastion_host_create_elastic_ip=config.bastion_host_create_elastic_ip,
4231
bastion_host_user_data=yaml.dump(config.bastion_host_user_data),
43-
titiler_buckets=config.titiler_buckets,
44-
data_access_role_arn=config.data_access_role_arn,
45-
auth_provider_jwks_url=config.auth_provider_jwks_url,
32+
**config
4633
)
4734
app.synth()

config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class Config(BaseSettings):
5454
description="Number of NAT gateways to create",
5555
default=DEFAULT_NAT_GATEWAY_COUNT,
5656
)
57+
bastion_host: Optional[bool] = pydantic.Field(
58+
description="""Whether to create a bastion host. It can typically
59+
be used to make administrative connections to the database if
60+
`public_db_subnet` is False""",
61+
default=True,
62+
)
5763
bastion_host_create_elastic_ip: Optional[bool] = pydantic.Field(
5864
description="Whether to create an elastic IP for the bastion host",
5965
default=False,

eoapi_template/pgStacInfra.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(
2626
stac_api_lambda_name: str,
2727
titiler_pgstac_api_lambda_name: str,
2828
tipg_api_lambda_name: str,
29+
bastion_host: bool,
2930
bastion_host_allow_ip_list: list,
3031
bastion_host_create_elastic_ip: bool,
3132
titiler_buckets: list,
@@ -98,17 +99,18 @@ def __init__(
9899
),
99100
)
100101

101-
BastionHost(
102-
self,
103-
"bastion-host",
104-
vpc=vpc,
105-
db=pgstac_db.db,
106-
ipv4_allowlist=bastion_host_allow_ip_list,
107-
user_data=aws_ec2.UserData.custom(bastion_host_user_data)
108-
if bastion_host_user_data
109-
else aws_ec2.UserData.for_linux(),
110-
create_elastic_ip=bastion_host_create_elastic_ip,
111-
)
102+
if bastion_host:
103+
BastionHost(
104+
self,
105+
"bastion-host",
106+
vpc=vpc,
107+
db=pgstac_db.db,
108+
ipv4_allowlist=bastion_host_allow_ip_list,
109+
user_data=aws_ec2.UserData.custom(bastion_host_user_data)
110+
if bastion_host_user_data
111+
else aws_ec2.UserData.for_linux(),
112+
create_elastic_ip=bastion_host_create_elastic_ip,
113+
)
112114

113115
if data_access_role_arn:
114116
# importing provided role from arn.

0 commit comments

Comments
 (0)