Skip to content

Commit 80f010d

Browse files
authored
Fix model deploy pr (#428)
* fix: Add --all flag to cdk deploy for multi-stack deployments The model deployment template creates multiple CDK stacks (pipeline + cross-region + endpoint stacks per environment). Without --all flag, cdk deploy fails when multiple stacks exist. This fix ensures the CodeBuild project can deploy all stacks in cross-account/cross-region configurations. * feat: Add region validation for cross-region deployment --------- Co-authored-by: Nuri Boardman <nurboard@amazon.com>
1 parent 83bcc00 commit 80f010d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

modules/sagemaker/sagemaker-templates/templates/model_deploy/product_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def __init__(
203203
"npm install -g aws-cdk",
204204
"python -m pip install -r requirements.txt",
205205
f"export REPOSITORY_TYPE={repository_type.value}",
206-
'cdk deploy --require-approval never --app "python app.py" ',
206+
'cdk deploy --all --require-approval never --app "python app.py" ',
207207
]
208208
}
209209
},

modules/sagemaker/sagemaker-templates/templates/model_deploy/seed_code/deploy_app/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
from deploy_app.pipeline_stack import PipelineStack
66

77
app = cdk.App()
8+
9+
# All deployment regions must match - cross-region endpoint deployment is not supported
10+
# because model packages contain region-specific container image URIs
11+
regions = {
12+
"dev": constants.DEV_REGION,
13+
"pre-prod": constants.PRE_PROD_REGION,
14+
"prod": constants.PROD_REGION,
15+
}
16+
mismatched = {k: v for k, v in regions.items() if v != constants.DEV_REGION}
17+
if mismatched:
18+
raise ValueError(f"All deployment regions must match dev region ({constants.DEV_REGION}). Mismatched: {mismatched}")
19+
820
PipelineStack(
921
app,
1022
f"{constants.PROJECT_NAME}-pipeline",

0 commit comments

Comments
 (0)