Skip to content

Commit 99c724e

Browse files
committed
[sdlf-foundations][cdk] ability to provide parameter values without --parameters
1 parent 2b7495c commit 99c724e

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

sdlf-foundations/deployspec.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ deploy:
1212
build:
1313
commands:
1414
- |-
15-
cdk deploy --all --require-approval never --progress events --app "python src/app.py" --outputs-file ./cdk-exports.json \
16-
--no-previous-parameters \
17-
--parameters pOrg="$SEEDFARMER_PARAMETER_ORG" \
18-
--parameters pDomain="$SEEDFARMER_PARAMETER_DOMAIN" \
19-
--parameters pChildAccountId="$AWS_ACCOUNT_ID"
15+
env | grep "SEEDFARMER"
16+
cdk deploy --all --require-approval never --progress events --app "python src/app.py" --outputs-file ./cdk-exports.json
2017
- seedfarmer metadata convert -f cdk-exports.json || true
2118
destroy:
2219
phases:

sdlf-foundations/src/app.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@
1212

1313
if project_name:
1414
stack_name = f"{project_name}-{deployment_name}-{module_name}"
15+
param_prefix = "SEEDFARMER_PARAMETER_"
1516
else: # app.py not used in a seedfarmer context somehow
1617
stack_name = "sdlf-foundations"
18+
param_prefix = ""
19+
20+
21+
def _param(name: str, default: str = None) -> str:
22+
return os.getenv(f"{param_prefix}{name}", default)
23+
1724

1825
app = cdk.App()
1926
stack = cdk.Stack(app, stack_name)
20-
stack_foundations = Foundations(stack, "foundations")
27+
stack_foundations = Foundations(
28+
stack,
29+
"foundations",
30+
org=_param("ORG"),
31+
data_domain=_param("DATA_DOMAIN"),
32+
account_id=os.getenv("CDK_DEFAULT_ACCOUNT"),
33+
)
2134

2235
cdk.CfnOutput(
2336
scope=stack,

sdlf-foundations/src/foundations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class Foundations(Construct):
2929
external_interface = {}
3030

31-
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
31+
def __init__(self, scope: Construct, id: str, org: str, data_domain: str, account_id: str, **kwargs) -> None:
3232
super().__init__(scope, id)
3333

3434
dirname = os.path.dirname(__file__)
@@ -50,6 +50,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
5050
type="String",
5151
allowed_pattern="(\\d{12}|^$)",
5252
constraint_description="Must be an AWS account ID",
53+
default=str(account_id),
5354
)
5455
p_childaccountid.override_logical_id("pChildAccountId")
5556
p_org = CfnParameter(
@@ -58,13 +59,15 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
5859
description="Name of the organization owning the datalake (all lowercase, no symbols or spaces)",
5960
type="String",
6061
allowed_pattern="[a-z0-9]{2,9}",
62+
default=org,
6163
)
6264
p_org.override_logical_id("pOrg")
6365
p_domain = CfnParameter(
6466
self,
6567
"pDomain",
6668
description="Data domain name",
6769
type="String",
70+
default=data_domain,
6871
)
6972
p_domain.override_logical_id("pDomain")
7073
# p_cloudwatchlogsretentionindays = CfnParameter(self, "pCloudWatchLogsRetentionInDays",

0 commit comments

Comments
 (0)