Skip to content

Commit

Permalink
Merge pull request #3688 from aws/release-v1.93.0
Browse files Browse the repository at this point in the history
Release 1.93.0 (to main)
  • Loading branch information
aaythapa authored Nov 21, 2024
2 parents 4960606 + b5df724 commit 564d7ad
Show file tree
Hide file tree
Showing 58 changed files with 3,962 additions and 569 deletions.
1 change: 1 addition & 0 deletions .cfnlintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ ignore_templates:
- tests/translator/output/**/function_with_intrinsics_resource_attribute.json # CFN now supports intrinsics in DeletionPolicy
- tests/translator/output/**/function_with_snapstart.json # Snapstart intentionally not attached to a lambda version which causes lint issues
- tests/translator/output/**/managed_policies_everything.json # intentionally contains wrong arns
- tests/translator/output/**/function_with_metrics_config.json
ignore_checks:
- E2531 # Deprecated runtime; not relevant for transform tests
- E2533 # Another deprecated runtime; not relevant for transform tests
Expand Down
5 changes: 5 additions & 0 deletions docs/globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Currently, the following resources and properties are being supported:
EphemeralStorage:
RuntimeManagementConfig:
LoggingConfig:
FileSystemConfigs:
Api:
# Properties of AWS::Serverless::Api
Expand Down Expand Up @@ -113,6 +114,10 @@ Currently, the following resources and properties are being supported:
# Properties of AWS::Serverless::SimpleTable
SSESpecification:
LayerVersion:
# Properties of AWS::Serverless::LayerVersion
PublishLambdaVersion:
Implicit APIs
~~~~~~~~~~~~~

Expand Down
2 changes: 0 additions & 2 deletions integration/combination/test_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ def tearDown(self):
("combination/connector_event_rule_to_sqs_write",),
("combination/connector_event_rule_to_sns_write",),
("combination/connector_event_rule_to_sfn_write",),
("combination/connector_event_rule_to_eb_default_write",),
("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_sqs_to_function",),
Expand Down
53 changes: 53 additions & 0 deletions integration/combination/test_connectors_event_rule_eb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from unittest import SkipTest
from unittest.case import skipIf

from parameterized import parameterized
from tenacity import retry, retry_if_exception, stop_after_attempt

from integration.config.service_names import EVENT_RULE_WITH_EVENT_BUS
from integration.conftest import clean_bucket
from integration.helpers.base_test import BaseTest
from integration.helpers.resource import current_region_does_not_support

retry_once = retry(
stop=stop_after_attempt(2),
# unittest raises SkipTest for skipping tests
retry=retry_if_exception(lambda e: not isinstance(e, SkipTest)),
)


@skipIf(
current_region_does_not_support([EVENT_RULE_WITH_EVENT_BUS]),
"EVENT_RULE_WITH_EVENT_BUS is not supported in this testing region",
)
class TestConnectorsWithEventRuleToEB(BaseTest):
def tearDown(self):
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
# manually empty the bucket to allow stacks to be deleted successfully.
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
if bucket_name:
clean_bucket(bucket_name, self.client_provider.s3_client)
super().tearDown()

@parameterized.expand(
[
("combination/connector_event_rule_to_eb_default_write",),
("combination/connector_event_rule_to_eb_custom_write",),
]
)
@retry_once
def test_connector_event_rule_eb_by_invoking_a_function(self, template_file_path):
self.skip_using_service_detector(template_file_path)
self.create_and_verify_stack(template_file_path)

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)
36 changes: 36 additions & 0 deletions integration/combination/test_function_with_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,42 @@ def test_alias_with_event_sources_get_correct_permissions(self):
function_policy = json.loads(function_policy_str)
self.assertEqual(len(function_policy["Statement"]), len(permission_resources))

def test_function_with_alias_and_layer_version(self):
self.create_and_verify_stack("combination/function_with_alias_all_properties_and_layer_version")
alias_name = "Live"
function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
version_ids = self.get_function_version_by_name(function_name)
self.assertEqual(["1"], version_ids)

alias = self.get_alias(function_name, alias_name)
self.assertEqual("1", alias["FunctionVersion"])

# Changing Description in the LayerVersion should create a new version, and leave the existing version intact
self.set_template_resource_property("MyLayer", "Description", "test123")
self.update_stack()

version_ids = self.get_function_version_by_name(function_name)
self.assertEqual(["1", "2"], version_ids)

alias = self.get_alias(function_name, alias_name)
self.assertEqual("2", alias["FunctionVersion"])

# Changing ContentUri in LayerVersion should create a new version, and leave the existing version intact
self.set_template_resource_property("MyLayer", "ContentUri", self.file_to_s3_uri_map["layer2.zip"]["uri"])
self.update_stack()

version_ids = self.get_function_version_by_name(function_name)
self.assertEqual(["1", "2", "3"], version_ids)

alias = self.get_alias(function_name, alias_name)
self.assertEqual("3", alias["FunctionVersion"])

# Make sure the stack has only One Version & One Alias resource
alias = self.get_stack_resources("AWS::Lambda::Alias")
versions = self.get_stack_resources("AWS::Lambda::Version")
self.assertEqual(len(alias), 1)
self.assertEqual(len(versions), 1)

def get_function_version_by_name(self, function_name):
lambda_client = self.client_provider.lambda_client
versions = lambda_client.list_versions_by_function(FunctionName=function_name)["Versions"]
Expand Down
4 changes: 4 additions & 0 deletions integration/config/file_to_s3_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"type": "s3",
"uri": ""
},
"layer2.zip": {
"type": "s3",
"uri": ""
},
"swagger1.json": {
"type": "s3",
"uri": ""
Expand Down
1 change: 1 addition & 0 deletions integration/config/service_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
APP_SYNC = "AppSync"
SNS_FILTER_POLICY_SCOPE = "SnsFilterPolicyScope"
LOGS = "Logs"
EVENT_RULE_WITH_EVENT_BUS = "EventRuleWithEventBus"
1 change: 1 addition & 0 deletions integration/helpers/file_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"code.zip": {"type": "s3", "uri": ""},
"code2.zip": {"type": "s3", "uri": ""},
"layer1.zip": {"type": "s3", "uri": ""},
"layer2.zip": {"type": "s3", "uri": ""},
"swagger1.json": {"type": "s3", "uri": ""},
"swagger2.json": {"type": "s3", "uri": ""},
"binary-media.zip": {"type": "s3", "uri": ""},
Expand Down
Binary file added integration/resources/code/layer2.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"LogicalResourceId": "MyLambdaFunction",
"ResourceType": "AWS::Lambda::Function"
},
{
"LogicalResourceId": "MyLambdaFunctionRole",
"ResourceType": "AWS::IAM::Role"
},
{
"LogicalResourceId": "MyLambdaFunctionAliasLive",
"ResourceType": "AWS::Lambda::Alias"
},
{
"LogicalResourceId": "MyLambdaFunctionVersion",
"ResourceType": "AWS::Lambda::Version"
},
{
"LogicalResourceId": "MyLayer",
"ResourceType": "AWS::Lambda::LayerVersion"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"LogicalResourceId": "SuperCoolAPI",
"ResourceType": "AWS::AppSync::GraphQLApi"
},
{
"LogicalResourceId": "SuperCoolAPICloudWatchRole",
"ResourceType": "AWS::IAM::Role"
},
{
"LogicalResourceId": "SuperCoolAPISchema",
"ResourceType": "AWS::AppSync::GraphQLSchema"
},
{
"LogicalResourceId": "SuperCoolAPIQuerygetBook",
"ResourceType": "AWS::AppSync::Resolver"
},
{
"LogicalResourceId": "SuperCoolAPINoneDataSource",
"ResourceType": "AWS::AppSync::DataSource"
},
{
"LogicalResourceId": "SuperCoolAPIprocessQuery",
"ResourceType": "AWS::AppSync::FunctionConfiguration"
},
{
"LogicalResourceId": "SuperCoolAPIMyApiKey",
"ResourceType": "AWS::AppSync::ApiKey"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPI",
"ResourceType": "AWS::AppSync::GraphQLApi"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPICloudWatchRole",
"ResourceType": "AWS::IAM::Role"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPISchema",
"ResourceType": "AWS::AppSync::GraphQLSchema"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPIQuerygetBook",
"ResourceType": "AWS::AppSync::Resolver"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPINoneDataSource",
"ResourceType": "AWS::AppSync::DataSource"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPIprocessQuery",
"ResourceType": "AWS::AppSync::FunctionConfiguration"
},
{
"LogicalResourceId": "IntrospectionDisableSuperCoolAPIMyApiKey",
"ResourceType": "AWS::AppSync::ApiKey"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Resources:
MyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ${codeuri}
Handler: index.handler
Runtime: nodejs20.x
AutoPublishAlias: Live
AutoPublishAliasAllProperties: true
Layers:
- !Ref MyLayer

MyLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: ${contenturi}
RetentionPolicy: Delete
PublishLambdaVersion: true
Description: test
Metadata:
SamTransformTest: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Transform: AWS::Serverless-2016-10-31
Resources:
SuperCoolAPI:
Type: AWS::Serverless::GraphQLApi
Properties:
SchemaInline: |
type Book {
bookName: String
id: ID
}
type Query { getBook(bookName: String): Book }
OwnerContact: blah-blah
Auth:
Type: API_KEY
ApiKeys:
MyApiKey: {}
Functions:
processQuery:
Runtime:
Name: APPSYNC_JS
Version: 1.0.0
DataSource: NONE
InlineCode: |
import { util } from '@aws-appsync/utils';
export function request(ctx) {
const id = util.autoId();
return { payload: { ...ctx.args, id } };
}
export function response(ctx) {
return ctx.result;
}
Resolvers:
Query:
getBook:
Pipeline:
- processQuery

IntrospectionDisableSuperCoolAPI:
Type: AWS::Serverless::GraphQLApi
Properties:
SchemaInline: |
type Book {
bookName: String
id: ID
}
type Query { getBook(bookName: String): Book }
OwnerContact: blah-blah
IntrospectionConfig: DISABLED
QueryDepthLimit: 10
ResolverCountLimit: 100
Auth:
Type: API_KEY
ApiKeys:
MyApiKey: {}
Functions:
processQuery:
Runtime:
Name: APPSYNC_JS
Version: 1.0.0
DataSource: NONE
InlineCode: |
import { util } from '@aws-appsync/utils';
export function request(ctx) {
const id = util.autoId();
return { payload: { ...ctx.args, id } };
}
export function response(ctx) {
return ctx.result;
}
Resolvers:
Query:
getBook:
Pipeline:
- processQuery
Outputs:
SuperCoolAPI:
Description: AppSync API
Value: !GetAtt SuperCoolAPI.GraphQLUrl
MyApiKey:
Description: API Id
Value: !GetAtt SuperCoolAPIMyApiKey.ApiKey
IntrospectionDisableSuperCoolAPI:
Description: AppSync API
Value: !GetAtt IntrospectionDisableSuperCoolAPI.GraphQLUrl
IntrospectionDisableSuperCoolAPIMyApiKey:
Description: API Id
Value: !GetAtt IntrospectionDisableSuperCoolAPIMyApiKey.ApiKey

Metadata:
SamTransformTest: true
Loading

0 comments on commit 564d7ad

Please sign in to comment.