Skip to content

Commit

Permalink
Merge pull request #3594 from aws/release-v1.89.0
Browse files Browse the repository at this point in the history
Release 1.89.0 (to main)
  • Loading branch information
godwingrs22 committed May 16, 2024
2 parents e7ab742 + 1268fd6 commit 44562dc
Show file tree
Hide file tree
Showing 21 changed files with 22,414 additions and 3,650 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Resources:

MyTopic:
Type: AWS::SNS::Topic
Properties:
KmsMasterKeyId: alias/aws/sns

MyConnector:
Type: AWS::Serverless::Connector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ Resources:
Type: AWS::Kinesis::Stream
Properties:
ShardCount: 1
StreamEncryption:
EncryptionType: KMS
KeyId: alias/aws/kinesis

# What an irony the I can't use AWS::Serverless::SimpleTable here because it doesn't support streams specification
MyTable:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ Resources:
Condition: MyCondition
Properties:
ShardCount: 1
StreamEncryption:
EncryptionType: KMS
KeyId: alias/aws/kinesis

MyDynamoDB:
UpdateReplacePolicy: Delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ Resources:
Condition: MyCondition
Properties:
ShardCount: 1
StreamEncryption:
EncryptionType: KMS
KeyId: alias/aws/kinesis

MyDynamoDB:
Type: AWS::DynamoDB::Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ Resources:
Type: AWS::Kinesis::Stream
Properties:
ShardCount: 1
StreamEncryption:
EncryptionType: KMS
KeyId: alias/aws/kinesis
Metadata:
SamTransformTest: true
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ Resources:
Type: AWS::Kinesis::Stream
Properties:
ShardCount: 1
StreamEncryption:
EncryptionType: KMS
KeyId: alias/aws/kinesis
Metadata:
SamTransformTest: true
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ Resources:

MyTopic:
Type: AWS::SNS::Topic
Properties:
KmsMasterKeyId: alias/aws/sns
Metadata:
SamTransformTest: true
2 changes: 1 addition & 1 deletion samtranslator/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.88.0"
__version__ = "1.89.0"
17 changes: 13 additions & 4 deletions samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast

from samtranslator.feature_toggle.feature_toggle import FeatureToggle
from samtranslator.metrics.method_decorator import cw_timer
from samtranslator.model import Resource
from samtranslator.model.apigateway import (
Expand Down Expand Up @@ -40,6 +41,8 @@

LOG = logging.getLogger(__name__)

FEATURE_FLAG_NORMALIZED_OPENAPI_VERSION = "normalized_open_api_version"

_CORS_WILDCARD = "'*'"
CorsProperties = namedtuple(
"CorsProperties", ["AllowMethods", "AllowHeaders", "AllowOrigin", "MaxAge", "AllowCredentials"]
Expand Down Expand Up @@ -205,6 +208,7 @@ def __init__( # noqa: PLR0913
mode: Optional[Intrinsicable[str]] = None,
api_key_source_type: Optional[Intrinsicable[str]] = None,
always_deploy: Optional[bool] = False,
feature_toggle: Optional[FeatureToggle] = None,
):
"""Constructs an API Generator class that generates API Gateway resources
Expand Down Expand Up @@ -261,6 +265,7 @@ def __init__( # noqa: PLR0913
self.mode = mode
self.api_key_source_type = api_key_source_type
self.always_deploy = always_deploy
self.feature_toggle = feature_toggle

def _construct_rest_api(self) -> ApiGatewayRestApi:
"""Constructs and returns the ApiGateway RestApi.
Expand Down Expand Up @@ -1125,11 +1130,15 @@ def _openapi_postprocess(self, definition_body: Dict[str, Any]) -> Dict[str, Any
if definition_body.get("swagger") is not None:
return definition_body

if definition_body.get("openapi") is not None and self.open_api_version is None:
self.open_api_version = definition_body.get("openapi")
if self.feature_toggle and self.feature_toggle.is_enabled(FEATURE_FLAG_NORMALIZED_OPENAPI_VERSION):
normalized_open_api_version = definition_body.get("openapi", self.open_api_version)
elif definition_body.get("openapi") is not None and self.open_api_version is None:
normalized_open_api_version = definition_body.get("openapi")
else:
normalized_open_api_version = self.open_api_version

if self.open_api_version and SwaggerEditor.safe_compare_regex_with_string(
SwaggerEditor._OPENAPI_VERSION_3_REGEX, self.open_api_version
if normalized_open_api_version and SwaggerEditor.safe_compare_regex_with_string(
SwaggerEditor._OPENAPI_VERSION_3_REGEX, normalized_open_api_version
):
if definition_body.get("securityDefinitions"):
components = definition_body.get("components", Py27Dict())
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ def to_cloudformation(self, **kwargs) -> List[Resource]: # type: ignore[no-unty
shared_api_usage_plan = kwargs.get("shared_api_usage_plan")
template_conditions = kwargs.get("conditions")
route53_record_set_groups = kwargs.get("route53_record_set_groups", {})
feature_toggle = kwargs.get("feature_toggle")

api_generator = ApiGenerator(
self.logical_id,
Expand Down Expand Up @@ -1330,6 +1331,7 @@ def to_cloudformation(self, **kwargs) -> List[Resource]: # type: ignore[no-unty
mode=self.Mode,
api_key_source_type=self.ApiKeySourceType,
always_deploy=self.AlwaysDeploy,
feature_toggle=feature_toggle,
)

generated_resources = api_generator.to_cloudformation(redeploy_restapi_parameters, route53_record_set_groups)
Expand Down
Loading

0 comments on commit 44562dc

Please sign in to comment.