Skip to content

Commit 1a6b7bd

Browse files
authored
fix: Allow Dynamic Reference in CodeUri Property if no / used (#3472)
1 parent a6caeeb commit 1a6b7bd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

samtranslator/model/s3_utils/uri_parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ def construct_s3_location_object(
8888
else:
8989
# SSM Pattern found here https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html
9090
ssm_pattern = r"{{resolve:(ssm|ssm-secure|secretsmanager):[a-zA-Z0-9_.\-/]+(:\d+)?}}"
91-
if search(ssm_pattern, location_uri):
91+
match = search(ssm_pattern, location_uri)
92+
if match and match.group(0) and "/" in match.group(0):
9293
raise InvalidResourceException(
9394
logical_id,
94-
f"Dynamic reference detected in '{property_name}'. Please "
95+
f"Unsupported dynamic reference detected in '{property_name}'. Please "
9596
"consider using alternative 'FunctionCode' object format.",
9697
)
9798

tests/translator/output/error_function_with_dynamic_ref_codeuri.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"Invalid Serverless Application Specification document. ",
44
"Number of errors found: 1. ",
55
"Resource with id [MinimalFunction] is invalid. ",
6-
"Dynamic reference detected in 'CodeUri'. ",
6+
"Unsupported dynamic reference detected in 'CodeUri'. ",
77
"Please consider using alternative 'FunctionCode' object format."
88
],
9-
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MinimalFunction] is invalid. Dynamic reference detected in 'CodeUri'. Please consider using alternative 'FunctionCode' object format.",
9+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MinimalFunction] is invalid. Unsupported dynamic reference detected in 'CodeUri'. Please consider using alternative 'FunctionCode' object format.",
1010
"errors": [
1111
{
12-
"errorMessage": "Resource with id [MinimalFunction] is invalid. Dynamic reference detected in 'CodeUri'. Please consider using alternative 'FunctionCode' object format."
12+
"errorMessage": "Resource with id [MinimalFunction] is invalid. Unsupported dynamic reference detected in 'CodeUri'. Please consider using alternative 'FunctionCode' object format."
1313
}
1414
]
1515
}

0 commit comments

Comments
 (0)