Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Give a more appropriate warning with Availability Dip #3362

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions samtranslator/plugins/application/serverless_app_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import json
import logging
import re
from time import sleep
from typing import Any, Callable, Dict, List, Optional, Tuple

Expand Down Expand Up @@ -150,6 +151,14 @@ def on_before_transform_template(self, template_dict): # type: ignore[no-untype
raise InvalidResourceException(
logical_id, "Serverless Application Repository is not available in this region."
)
# SSM Pattern found here https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html
ssm_pattern = r"{{resolve:ssm:[a-zA-Z0-9_.\-/]+(:\d+)?}}"
if re.search(ssm_pattern, app_id):
raise InvalidResourceException(
logical_id,
"Serverless Application Repostiory does not support dynamic reference in 'ApplicationId' property.",
)

self._make_service_call_with_retry(service_call, app_id, semver, key, logical_id) # type: ignore[no-untyped-call]
except InvalidResourceException as e:
# Catch all InvalidResourceExceptions, raise those in the before_resource_transform target.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Resources:
CLOUDDELIVERY:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: '{{resolve:ssm:/elw/test/sar-app}}'
SemanticVersion: 5.2.17
14 changes: 14 additions & 0 deletions tests/translator/output/error_sar_with_dynamic_reference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"_autoGeneratedBreakdownErrorMessage": [
"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."
],
"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.",
"errors": [
{
"errorMessage": "Resource with id [CLOUDDELIVERY] is invalid. Serverless Application Repostiory does not support dynamic reference in 'ApplicationId' property."
}
]
}
Loading