Skip to content

Commit 559d6b7

Browse files
authored
Merge pull request #3775 from aws/release-v1.98.0
Release 1.98.0 (to main)
2 parents dba5126 + ad5b4d6 commit 559d6b7

17 files changed

+2214
-359
lines changed

samtranslator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.97.0"
1+
__version__ = "1.98.0"

samtranslator/model/sam_resources.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" SAM macro definitions """
22

33
import copy
4+
import re
45
from contextlib import suppress
56
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, cast
67

@@ -238,7 +239,6 @@ class SamFunction(SamResourceMacro):
238239

239240
# DeadLetterQueue
240241
dead_letter_queue_policy_actions = {"SQS": "sqs:SendMessage", "SNS": "sns:Publish"}
241-
#
242242

243243
# Conditions
244244
conditions: Dict[str, Any] = {} # TODO: Replace `Any` with something more specific
@@ -325,7 +325,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P
325325
resources.append(url_permission)
326326

327327
self._validate_deployment_preference_and_add_update_policy(
328-
kwargs.get("deployment_preference_collection", None),
328+
kwargs.get("deployment_preference_collection"),
329329
lambda_alias,
330330
intrinsics_resolver,
331331
cast(IntrinsicsResolver, mappings_resolver), # TODO: better handle mappings_resolver's Optional
@@ -1002,7 +1002,22 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV
10021002
if not name:
10031003
raise InvalidResourceException(self.logical_id, "Alias name is required to create an alias")
10041004

1005-
logical_id = f"{function.logical_id}Alias{name}"
1005+
# Validate alias name against the required pattern: (?!^[0-9]+$)([a-zA-Z0-9-_]+)
1006+
# This ensures the alias name:
1007+
# 1. Contains only alphanumeric characters, hyphens, and underscores
1008+
# 2. Is not purely numeric
1009+
ALIAS_REGEX = r"(?!^[0-9]+$)([a-zA-Z0-9\-_]+)$"
1010+
if not re.match(ALIAS_REGEX, name):
1011+
raise InvalidResourceException(
1012+
self.logical_id,
1013+
f"AutoPublishAlias name ('{name}') must contain only alphanumeric characters, hyphens, or underscores matching (?!^[0-9]+$)([a-zA-Z0-9-_]+) pattern.",
1014+
)
1015+
1016+
# Strip hyphens and underscores from the alias name for the logical ID
1017+
# This ensures the logical ID contains only alphanumeric characters
1018+
alias_alphanumeric_name = name.replace("-", "D").replace("_", "U")
1019+
1020+
logical_id = f"{function.logical_id}Alias{alias_alphanumeric_name}"
10061021
alias = LambdaAlias(logical_id=logical_id, attributes=self.get_passthrough_resource_attributes())
10071022
alias.Name = name
10081023
alias.FunctionName = function.get_runtime_attr("name")
@@ -1014,7 +1029,7 @@ def _construct_alias(self, name: str, function: LambdaFunction, version: LambdaV
10141029

10151030
def _validate_deployment_preference_and_add_update_policy( # noqa: PLR0913
10161031
self,
1017-
deployment_preference_collection: DeploymentPreferenceCollection,
1032+
deployment_preference_collection: Optional[DeploymentPreferenceCollection],
10181033
lambda_alias: Optional[LambdaAlias],
10191034
intrinsics_resolver: IntrinsicsResolver,
10201035
mappings_resolver: IntrinsicsResolver,

samtranslator/region_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def is_apigw_edge_configuration_supported(cls) -> bool:
1818
:return: True, if API Gateway does not support Edge configuration
1919
"""
2020
partition = ArnGenerator.get_partition_name()
21-
if partition.startswith("aws-iso") or partition in ["aws-us-gov", "aws-cn"]:
21+
if partition.startswith("aws-iso") or partition in ["aws-us-gov", "aws-cn", "aws-eusc"]:
2222
return False
2323
return True
2424

samtranslator/schema/schema.json

Lines changed: 93 additions & 93 deletions
Large diffs are not rendered by default.

samtranslator/translator/arn_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def _region_to_partition(region: str) -> str:
2424
"us-gov": "aws-us-gov",
2525
"eu-isoe": "aws-iso-e",
2626
"us-isof": "aws-iso-f",
27+
"eusc-": "aws-eusc",
2728
}
2829
for key, value in region_to_partition_map.items():
2930
if region_string.startswith(key):

schema_source/cloudformation-docs.json

Lines changed: 456 additions & 157 deletions
Large diffs are not rendered by default.

schema_source/cloudformation.schema.json

Lines changed: 93 additions & 93 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Resources:
2+
MyFunction:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
CodeUri: s3://sam-demo-bucket/hello.zip
6+
Handler: hello.handler
7+
Runtime: python3.9
8+
# Using an invalid alias name with special characters that can't be properly transformed
9+
AutoPublishAlias: invalid*alias@name
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Resources:
2+
FunctionAliasNameCamelCase:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
CodeUri: s3://sam-demo-bucket/hello.zip
6+
Handler: hello.handler
7+
Runtime: python3.9
8+
AutoPublishAlias: camelCaseName
9+
VersionDescription: sam-testing
10+
11+
FunctionAliasNameUpperCase:
12+
Type: AWS::Serverless::Function
13+
Properties:
14+
CodeUri: s3://sam-demo-bucket/hello.zip
15+
Handler: hello.handler
16+
Runtime: python3.9
17+
AutoPublishAlias: UPPERCASE
18+
VersionDescription: sam-testing
19+
20+
FunctionAliasNameLowerCase:
21+
Type: AWS::Serverless::Function
22+
Properties:
23+
CodeUri: s3://sam-demo-bucket/hello.zip
24+
Handler: hello.handler
25+
Runtime: python3.9
26+
AutoPublishAlias: lowercase
27+
VersionDescription: sam-testing
28+
29+
FunctionAliasNameUnderscore:
30+
Type: AWS::Serverless::Function
31+
Properties:
32+
CodeUri: s3://sam-demo-bucket/hello.zip
33+
Handler: hello.handler
34+
Runtime: python3.9
35+
AutoPublishAlias: _underscore_name_
36+
VersionDescription: sam-testing
37+
38+
FunctionAliasNameDash:
39+
Type: AWS::Serverless::Function
40+
Properties:
41+
CodeUri: s3://sam-demo-bucket/hello.zip
42+
Handler: hello.handler
43+
Runtime: python3.9
44+
AutoPublishAlias: underscore-name
45+
VersionDescription: sam-testing
46+
47+
FunctionAliasNameMix:
48+
Type: AWS::Serverless::Function
49+
Properties:
50+
CodeUri: s3://sam-demo-bucket/hello.zip
51+
Handler: hello.handler
52+
Runtime: python3.9
53+
AutoPublishAlias: underScoreNAME_with-dash-01234
54+
VersionDescription: sam-testing

0 commit comments

Comments
 (0)