Skip to content

Commit 1ef82c3

Browse files
committed
Add dependency to LAUNCH role constraint to fix SC issues in ap-southeast-2
1 parent f4856d2 commit 1ef82c3

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Then, click the **Add inline policy** link, switch to to the **JSON** tab, and p
192192
"Action": [
193193
"iam:GetRole",
194194
"iam:PassRole",
195-
"iam:getRolePolicy",
195+
"iam:GetRolePolicy",
196196
"iam:AttachRolePolicy",
197197
"iam:PutRolePolicy",
198198
"iam:DetachRolePolicy",

infra/service_catalog.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,24 @@ def __init__(
9292
role_arn=f"arn:{self.partition}:iam::{self.account}:role/service-role/AmazonSageMakerServiceCatalogProductsLaunchRole",
9393
)
9494

95-
aws_servicecatalog.CfnLaunchRoleConstraint(
95+
portfolio_association = aws_servicecatalog.CfnPortfolioPrincipalAssociation(
9696
self,
97-
"LaunchRoleConstraint",
97+
"PortfolioPrincipalAssociation",
9898
portfolio_id=portfolio.ref,
99-
product_id=product.ref,
100-
role_arn=launch_role.role_arn,
101-
description=f"Launch as {launch_role.role_arn}",
99+
principal_arn=execution_role_arn.value_as_string,
100+
principal_type="IAM",
102101
)
103102

104-
aws_servicecatalog.CfnPortfolioPrincipalAssociation(
103+
# Ensure we run the LaunchRoleConstrait last as there are timing issues on product/portfolio being created
104+
role_constraint = aws_servicecatalog.CfnLaunchRoleConstraint(
105105
self,
106-
"PortfolioPrincipalAssociation",
106+
"LaunchRoleConstraint",
107107
portfolio_id=portfolio.ref,
108-
principal_arn=execution_role_arn.value_as_string,
109-
principal_type="IAM",
108+
product_id=product.ref,
109+
role_arn=launch_role.role_arn,
110+
description=f"Launch as {launch_role.role_arn}",
110111
)
112+
role_constraint.add_depends_on(portfolio_association)
111113

112114
# Create the deployment asset as an output to pass to pipeline stack
113115
deployment_asset = aws_s3_assets.Asset(

lambda/api/lambda_register.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def lambda_handler(event, context):
9999
# If this endpoint does not match prefix or not enabled return Not Modified (304)
100100
endpoint_name = event["detail"]["EndpointName"]
101101
endpoint_tags = event["detail"]["Tags"]
102-
endpoint_enabled = endpoint_tags.get("ab-testing:enabled", "false").lower() == "true"
102+
endpoint_enabled = endpoint_tags.get("ab-testing:enabled", "").lower() == "true"
103103
if not (endpoint_name.startswith(ENDPOINT_PREFIX) and endpoint_enabled):
104104
error_message = (
105105
f"Endpoint: {endpoint_name} not enabled for prefix: {ENDPOINT_PREFIX}"

0 commit comments

Comments
 (0)