Skip to content

Commit

Permalink
Merge pull request #3118 from aws/release-v1.65.0
Browse files Browse the repository at this point in the history
Release 1.65.0 (to main)
  • Loading branch information
xazhao committed Apr 19, 2023
2 parents c916e66 + cc5addd commit 5252262
Show file tree
Hide file tree
Showing 39 changed files with 58,374 additions and 6,957 deletions.
2 changes: 1 addition & 1 deletion bin/run_cfn_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VENV=.venv_cfn_lint
# See https://github.com/aws/serverless-application-model/issues/1042
if [ ! -d "${VENV}" ]; then
python3 -m venv "${VENV}"
"${VENV}/bin/python" -m pip install cfn-lint --quiet
fi

"${VENV}/bin/python" -m pip install cfn-lint==0.75.0 --upgrade --quiet
"${VENV}/bin/cfn-lint" --format parseable
2 changes: 1 addition & 1 deletion bin/sam-translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def transform_template(input_file_path, output_file_path): # type: ignore[no-un
except InvalidDocumentException as e:
error_message = reduce(lambda message, error: message + " " + error.message, e.causes, e.message)
LOG.error(error_message)
errors = map(lambda cause: cause.message, e.causes)
errors = (cause.message for cause in e.causes)
LOG.error(errors)


Expand Down
25 changes: 24 additions & 1 deletion integration/combination/test_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def tearDown(self):
("combination/connector_event_rule_to_eb_custom_write",),
("combination/connector_event_rule_to_lambda_write",),
("combination/connector_event_rule_to_lambda_write_multiple",),
("combination/connector_function_to_location_place_index",),
("combination/connector_mix_destination",),
("combination/connector_sqs_to_function",),
("combination/connector_sns_to_function_write",),
Expand All @@ -75,6 +74,30 @@ def test_connector_by_invoking_a_function(self, template_file_path):
self.assertEqual(response.get("StatusCode"), 200)
self.assertEqual(response.get("FunctionError"), None)

@parameterized.expand(
[
("combination/connector_function_to_location_place_index",),
]
)
@retry_once
def test_connector_by_invoking_a_function_with_parameters(self, template_file_path):
parameters = []
parameters.append(self.generate_parameter("IndexName", f"PlaceIndex-{generate_suffix()}"))
self.skip_using_service_detector(template_file_path)
self.create_and_verify_stack(template_file_path, parameters)

lambda_function_name = self.get_physical_id_by_logical_id("TriggerFunction")
lambda_client = self.client_provider.lambda_client

request_params = {
"FunctionName": lambda_function_name,
"InvocationType": "RequestResponse",
"Payload": "{}",
}
response = lambda_client.invoke(**request_params)
self.assertEqual(response.get("StatusCode"), 200)
self.assertEqual(response.get("FunctionError"), None)

@parameterized.expand(
[
("combination/connector_sfn_to_function_without_policy",),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Transform: AWS::Serverless-2016-10-31-test

Parameters:
IndexName:
Type: String
Default: PlaceIndex

Resources:
TriggerFunction:
Type: AWS::Serverless::Function
Expand Down Expand Up @@ -35,14 +40,14 @@ Resources:
)
Environment:
Variables:
LOCATION_INDEX: !Sub ${AWS::StackName}-PI
LOCATION_INDEX: !Ref IndexName


MyPlace:
Type: AWS::Location::PlaceIndex
Properties:
DataSource: Here
IndexName: !Sub ${AWS::StackName}-PI
IndexName: !Ref IndexName

MyConnector:
Type: AWS::Serverless::Connector
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pytest-xdist>=2.5,<4
pytest-env>=0.6,<1
pytest-rerunfailures>=9.1,<12
pyyaml~=6.0
ruff==0.0.254 # loose the requirement once it is more stable
ruff==0.0.259 # loose the requirement once it is more stable

# Test requirements
pytest>=6.2,<8
Expand Down
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ select = [
"RUF", # Ruff-specific rules
"YTT", # flake8-2020
"UP", # pyupgrade
"C4", # flake8-comprehensions
]

# Mininal python version we support is 3.7
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.64.0"
__version__ = "1.65.0"
221 changes: 182 additions & 39 deletions samtranslator/internal/schema_source/aws_serverless_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
ResourceAttributes,
SamIntrinsicable,
get_prop,
passthrough_prop,
)

PROPERTIES_STEM = "sam-resource-api"
DOMAIN_STEM = "sam-property-api-domainconfiguration"
ROUTE53_STEM = "sam-property-api-route53configuration"
ENDPOINT_CONFIGURATION_STEM = "sam-property-api-endpointconfiguration"
DEFINITION_URI_STEM = "sam-property-api-apidefinition"

resourcepolicy = get_prop("sam-property-api-resourcepolicystatement")
cognitoauthorizeridentity = get_prop("sam-property-api-cognitoauthorizationidentity")
cognitoauthorizer = get_prop("sam-property-api-cognitoauthorizer")
Expand All @@ -24,11 +31,11 @@
usageplan = get_prop("sam-property-api-apiusageplan")
auth = get_prop("sam-property-api-apiauth")
cors = get_prop("sam-property-api-corsconfiguration")
route53 = get_prop("sam-property-api-route53configuration")
domain = get_prop("sam-property-api-domainconfiguration")
definitionuri = get_prop("sam-property-api-apidefinition")
endpointconfiguration = get_prop("sam-property-api-endpointconfiguration")
properties = get_prop("sam-resource-api")
route53 = get_prop(ROUTE53_STEM)
domain = get_prop(DOMAIN_STEM)
definitionuri = get_prop(DEFINITION_URI_STEM)
endpointconfiguration = get_prop(ENDPOINT_CONFIGURATION_STEM)
properties = get_prop(PROPERTIES_STEM)


class ResourcePolicy(BaseModel):
Expand Down Expand Up @@ -127,10 +134,26 @@ class Cors(BaseModel):


class Route53(BaseModel):
DistributionDomainName: Optional[PassThroughProp] = route53("DistributionDomainName")
EvaluateTargetHealth: Optional[PassThroughProp] = route53("EvaluateTargetHealth")
HostedZoneId: Optional[PassThroughProp] = route53("HostedZoneId")
HostedZoneName: Optional[PassThroughProp] = route53("HostedZoneName")
DistributionDomainName: Optional[PassThroughProp] = passthrough_prop(
ROUTE53_STEM,
"DistributionDomainName",
["AWS::Route53::RecordSetGroup.AliasTarget", "DNSName"],
)
EvaluateTargetHealth: Optional[PassThroughProp] = passthrough_prop(
ROUTE53_STEM,
"EvaluateTargetHealth",
["AWS::Route53::RecordSetGroup.AliasTarget", "EvaluateTargetHealth"],
)
HostedZoneId: Optional[PassThroughProp] = passthrough_prop(
ROUTE53_STEM,
"HostedZoneId",
["AWS::Route53::RecordSetGroup.RecordSet", "HostedZoneId"],
)
HostedZoneName: Optional[PassThroughProp] = passthrough_prop(
ROUTE53_STEM,
"HostedZoneName",
["AWS::Route53::RecordSetGroup.RecordSet", "HostedZoneName"],
)
IpV6: Optional[bool] = route53("IpV6")
SetIdentifier: Optional[PassThroughProp] # TODO: add docs
Region: Optional[PassThroughProp] # TODO: add docs
Expand All @@ -141,23 +164,59 @@ class Domain(BaseModel):
BasePath: Optional[PassThroughProp] = domain("BasePath")
NormalizeBasePath: Optional[bool] = domain("NormalizeBasePath")
CertificateArn: PassThroughProp = domain("CertificateArn")
DomainName: PassThroughProp = domain("DomainName")
DomainName: PassThroughProp = passthrough_prop(
DOMAIN_STEM,
"DomainName",
["AWS::ApiGateway::DomainName", "Properties", "DomainName"],
)
EndpointConfiguration: Optional[SamIntrinsicable[Literal["REGIONAL", "EDGE"]]] = domain("EndpointConfiguration")
MutualTlsAuthentication: Optional[PassThroughProp] = domain("MutualTlsAuthentication")
OwnershipVerificationCertificateArn: Optional[PassThroughProp] = domain("OwnershipVerificationCertificateArn")
MutualTlsAuthentication: Optional[PassThroughProp] = passthrough_prop(
DOMAIN_STEM,
"MutualTlsAuthentication",
["AWS::ApiGateway::DomainName", "Properties", "MutualTlsAuthentication"],
)
OwnershipVerificationCertificateArn: Optional[PassThroughProp] = passthrough_prop(
DOMAIN_STEM,
"OwnershipVerificationCertificateArn",
["AWS::ApiGateway::DomainName", "Properties", "OwnershipVerificationCertificateArn"],
)
Route53: Optional[Route53] = domain("Route53")
SecurityPolicy: Optional[PassThroughProp] = domain("SecurityPolicy")
SecurityPolicy: Optional[PassThroughProp] = passthrough_prop(
DOMAIN_STEM,
"SecurityPolicy",
["AWS::ApiGateway::DomainName", "Properties", "SecurityPolicy"],
)


class DefinitionUri(BaseModel):
Bucket: PassThroughProp = definitionuri("Bucket")
Key: PassThroughProp = definitionuri("Key")
Version: Optional[PassThroughProp] = definitionuri("Version")
Bucket: PassThroughProp = passthrough_prop(
DEFINITION_URI_STEM,
"Bucket",
["AWS::ApiGateway::RestApi.S3Location", "Bucket"],
)
Key: PassThroughProp = passthrough_prop(
DEFINITION_URI_STEM,
"Key",
["AWS::ApiGateway::RestApi.S3Location", "Key"],
)
Version: Optional[PassThroughProp] = passthrough_prop(
DEFINITION_URI_STEM,
"Version",
["AWS::ApiGateway::RestApi.S3Location", "Version"],
)


class EndpointConfiguration(BaseModel):
Type: Optional[PassThroughProp] = endpointconfiguration("Type")
VPCEndpointIds: Optional[PassThroughProp] = endpointconfiguration("VPCEndpointIds")
Type: Optional[PassThroughProp] = passthrough_prop(
ENDPOINT_CONFIGURATION_STEM,
"Type",
["AWS::ApiGateway::RestApi.EndpointConfiguration", "Types"],
)
VPCEndpointIds: Optional[PassThroughProp] = passthrough_prop(
ENDPOINT_CONFIGURATION_STEM,
"VPCEndpointIds",
["AWS::ApiGateway::RestApi.EndpointConfiguration", "VpcEndpointIds"],
)


Name = Optional[PassThroughProp]
Expand All @@ -180,53 +239,137 @@ class EndpointConfiguration(BaseModel):


class Properties(BaseModel):
AccessLogSetting: Optional[AccessLogSetting] = properties("AccessLogSetting")
ApiKeySourceType: Optional[PassThroughProp] = properties("ApiKeySourceType")
AccessLogSetting: Optional[AccessLogSetting] = passthrough_prop(
PROPERTIES_STEM,
"AccessLogSetting",
["AWS::ApiGateway::Stage", "Properties", "AccessLogSetting"],
)
ApiKeySourceType: Optional[PassThroughProp] = passthrough_prop(
PROPERTIES_STEM,
"ApiKeySourceType",
["AWS::ApiGateway::RestApi", "Properties", "ApiKeySourceType"],
)
Auth: Optional[Auth] = properties("Auth")
BinaryMediaTypes: Optional[BinaryMediaTypes] = properties("BinaryMediaTypes")
CacheClusterEnabled: Optional[CacheClusterEnabled] = properties("CacheClusterEnabled")
CacheClusterSize: Optional[CacheClusterSize] = properties("CacheClusterSize")
CanarySetting: Optional[CanarySetting] = properties("CanarySetting")
CacheClusterEnabled: Optional[CacheClusterEnabled] = passthrough_prop(
PROPERTIES_STEM,
"CacheClusterEnabled",
["AWS::ApiGateway::Stage", "Properties", "CacheClusterEnabled"],
)
CacheClusterSize: Optional[CacheClusterSize] = passthrough_prop(
PROPERTIES_STEM,
"CacheClusterSize",
["AWS::ApiGateway::Stage", "Properties", "CacheClusterSize"],
)
CanarySetting: Optional[CanarySetting] = passthrough_prop(
PROPERTIES_STEM,
"CanarySetting",
["AWS::ApiGateway::Stage", "Properties", "CanarySetting"],
)
Cors: Optional[CorsType] = properties("Cors")
DefinitionBody: Optional[DictStrAny] = properties("DefinitionBody")
DefinitionUri: Optional[DefinitionUriType] = properties("DefinitionUri")
MergeDefinitions: Optional[MergeDefinitions] = properties("MergeDefinitions")
Description: Optional[PassThroughProp] = properties("Description")
Description: Optional[PassThroughProp] = passthrough_prop(
PROPERTIES_STEM,
"Description",
["AWS::ApiGateway::Stage", "Properties", "Description"],
)
DisableExecuteApiEndpoint: Optional[PassThroughProp] = properties("DisableExecuteApiEndpoint")
Domain: Optional[Domain] = properties("Domain")
EndpointConfiguration: Optional[EndpointConfigurationType] = properties("EndpointConfiguration")
FailOnWarnings: Optional[PassThroughProp] = properties("FailOnWarnings")
FailOnWarnings: Optional[PassThroughProp] = passthrough_prop(
PROPERTIES_STEM,
"FailOnWarnings",
["AWS::ApiGateway::RestApi", "Properties", "FailOnWarnings"],
)
GatewayResponses: Optional[GatewayResponses] = properties("GatewayResponses")
MethodSettings: Optional[MethodSettings] = properties("MethodSettings")
MinimumCompressionSize: Optional[MinimumCompressionSize] = properties("MinimumCompressionSize")
Mode: Optional[PassThroughProp] = properties("Mode")
MethodSettings: Optional[MethodSettings] = passthrough_prop(
PROPERTIES_STEM,
"MethodSettings",
["AWS::ApiGateway::Stage", "Properties", "MethodSettings"],
)
MinimumCompressionSize: Optional[MinimumCompressionSize] = passthrough_prop(
PROPERTIES_STEM,
"MinimumCompressionSize",
["AWS::ApiGateway::RestApi", "Properties", "MinimumCompressionSize"],
)
Mode: Optional[PassThroughProp] = passthrough_prop(
PROPERTIES_STEM,
"Mode",
["AWS::ApiGateway::RestApi", "Properties", "Mode"],
)
Models: Optional[DictStrAny] = properties("Models")
Name: Optional[Name] = properties("Name")
Name: Optional[Name] = passthrough_prop(
PROPERTIES_STEM,
"Name",
["AWS::ApiGateway::RestApi", "Properties", "Name"],
)
OpenApiVersion: Optional[OpenApiVersion] = properties("OpenApiVersion")
StageName: SamIntrinsicable[str] = properties("StageName")
Tags: Optional[DictStrAny] = properties("Tags")
TracingEnabled: Optional[TracingEnabled] = properties("TracingEnabled")
Variables: Optional[Variables] = properties("Variables")
TracingEnabled: Optional[TracingEnabled] = passthrough_prop(
PROPERTIES_STEM,
"TracingEnabled",
["AWS::ApiGateway::Stage", "Properties", "TracingEnabled"],
)
Variables: Optional[Variables] = passthrough_prop(
PROPERTIES_STEM,
"Variables",
["AWS::ApiGateway::Stage", "Properties", "Variables"],
)
AlwaysDeploy: Optional[AlwaysDeploy] = properties("AlwaysDeploy")


class Globals(BaseModel):
Auth: Optional[Auth] = properties("Auth")
Name: Optional[Name] = properties("Name")
Name: Optional[Name] = passthrough_prop(
PROPERTIES_STEM,
"Name",
["AWS::ApiGateway::RestApi", "Properties", "Name"],
)
DefinitionUri: Optional[PassThroughProp] = properties("DefinitionUri")
CacheClusterEnabled: Optional[CacheClusterEnabled] = properties("CacheClusterEnabled")
CacheClusterSize: Optional[CacheClusterSize] = properties("CacheClusterSize")
CacheClusterEnabled: Optional[CacheClusterEnabled] = passthrough_prop(
PROPERTIES_STEM,
"CacheClusterEnabled",
["AWS::ApiGateway::Stage", "Properties", "CacheClusterEnabled"],
)
CacheClusterSize: Optional[CacheClusterSize] = passthrough_prop(
PROPERTIES_STEM,
"CacheClusterSize",
["AWS::ApiGateway::Stage", "Properties", "CacheClusterSize"],
)
MergeDefinitions: Optional[MergeDefinitions] = properties("MergeDefinitions")
Variables: Optional[Variables] = properties("Variables")
Variables: Optional[Variables] = passthrough_prop(
PROPERTIES_STEM,
"Variables",
["AWS::ApiGateway::Stage", "Properties", "Variables"],
)
EndpointConfiguration: Optional[PassThroughProp] = properties("EndpointConfiguration")
MethodSettings: Optional[MethodSettings] = properties("MethodSettings")
BinaryMediaTypes: Optional[BinaryMediaTypes] = properties("BinaryMediaTypes")
MinimumCompressionSize: Optional[MinimumCompressionSize] = properties("MinimumCompressionSize")
MinimumCompressionSize: Optional[MinimumCompressionSize] = passthrough_prop(
PROPERTIES_STEM,
"MinimumCompressionSize",
["AWS::ApiGateway::RestApi", "Properties", "MinimumCompressionSize"],
)
Cors: Optional[CorsType] = properties("Cors")
GatewayResponses: Optional[GatewayResponses] = properties("GatewayResponses")
AccessLogSetting: Optional[AccessLogSetting] = properties("AccessLogSetting")
CanarySetting: Optional[CanarySetting] = properties("CanarySetting")
TracingEnabled: Optional[TracingEnabled] = properties("TracingEnabled")
AccessLogSetting: Optional[AccessLogSetting] = passthrough_prop(
PROPERTIES_STEM,
"AccessLogSetting",
["AWS::ApiGateway::Stage", "Properties", "AccessLogSetting"],
)
CanarySetting: Optional[CanarySetting] = passthrough_prop(
PROPERTIES_STEM,
"CanarySetting",
["AWS::ApiGateway::Stage", "Properties", "CanarySetting"],
)
TracingEnabled: Optional[TracingEnabled] = passthrough_prop(
PROPERTIES_STEM,
"TracingEnabled",
["AWS::ApiGateway::Stage", "Properties", "TracingEnabled"],
)
OpenApiVersion: Optional[OpenApiVersion] = properties("OpenApiVersion")
Domain: Optional[Domain] = properties("Domain")
AlwaysDeploy: Optional[AlwaysDeploy] = properties("AlwaysDeploy")
Expand Down
Loading

0 comments on commit 5252262

Please sign in to comment.