Skip to content

Commit 9c59fc7

Browse files
authored
fix: Give a more appropriate warning with Availability Dip (#3362)
1 parent 1bd228c commit 9c59fc7

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

samtranslator/plugins/application/serverless_app_plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import copy
22
import json
33
import logging
4+
import re
45
from time import sleep
56
from typing import Any, Callable, Dict, List, Optional, Tuple
67

@@ -150,6 +151,14 @@ def on_before_transform_template(self, template_dict): # type: ignore[no-untype
150151
raise InvalidResourceException(
151152
logical_id, "Serverless Application Repository is not available in this region."
152153
)
154+
# SSM Pattern found here https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html
155+
ssm_pattern = r"{{resolve:ssm:[a-zA-Z0-9_.\-/]+(:\d+)?}}"
156+
if re.search(ssm_pattern, app_id):
157+
raise InvalidResourceException(
158+
logical_id,
159+
"Serverless Application Repostiory does not support dynamic reference in 'ApplicationId' property.",
160+
)
161+
153162
self._make_service_call_with_retry(service_call, app_id, semver, key, logical_id) # type: ignore[no-untyped-call]
154163
except InvalidResourceException as e:
155164
# Catch all InvalidResourceExceptions, raise those in the before_resource_transform target.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Resources:
2+
CLOUDDELIVERY:
3+
Type: AWS::Serverless::Application
4+
Properties:
5+
Location:
6+
ApplicationId: '{{resolve:ssm:/elw/test/sar-app}}'
7+
SemanticVersion: 5.2.17
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"_autoGeneratedBreakdownErrorMessage": [
3+
"Invalid Serverless Application Specification document. ",
4+
"Number of errors found: 1. ",
5+
"Resource with id [CLOUDDELIVERY] is invalid. ",
6+
"Serverless Application Repostiory does not support dynamic reference in 'ApplicationId' property."
7+
],
8+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [CLOUDDELIVERY] is invalid. Serverless Application Repostiory does not support dynamic reference in 'ApplicationId' property.",
9+
"errors": [
10+
{
11+
"errorMessage": "Resource with id [CLOUDDELIVERY] is invalid. Serverless Application Repostiory does not support dynamic reference in 'ApplicationId' property."
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)