Skip to content

Commit 1b24618

Browse files
authored
Merge branch 'develop' into tmp/1731113614/main
2 parents 4960606 + 158c674 commit 1b24618

File tree

44 files changed

+2344
-558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2344
-558
lines changed

docs/globals.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Currently, the following resources and properties are being supported:
7575
EphemeralStorage:
7676
RuntimeManagementConfig:
7777
LoggingConfig:
78+
FileSystemConfigs:
7879
7980
Api:
8081
# Properties of AWS::Serverless::Api
@@ -113,6 +114,10 @@ Currently, the following resources and properties are being supported:
113114
# Properties of AWS::Serverless::SimpleTable
114115
SSESpecification:
115116
117+
LayerVersion:
118+
# Properties of AWS::Serverless::LayerVersion
119+
PublishLambdaVersion:
120+
116121
Implicit APIs
117122
~~~~~~~~~~~~~
118123

integration/combination/test_connectors.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ def tearDown(self):
8080
("combination/connector_event_rule_to_sqs_write",),
8181
("combination/connector_event_rule_to_sns_write",),
8282
("combination/connector_event_rule_to_sfn_write",),
83-
("combination/connector_event_rule_to_eb_default_write",),
84-
("combination/connector_event_rule_to_eb_custom_write",),
8583
("combination/connector_event_rule_to_lambda_write",),
8684
("combination/connector_event_rule_to_lambda_write_multiple",),
8785
("combination/connector_sqs_to_function",),
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from unittest import SkipTest
2+
from unittest.case import skipIf
3+
4+
from parameterized import parameterized
5+
from tenacity import retry, retry_if_exception, stop_after_attempt
6+
7+
from integration.config.service_names import EVENT_RULE_WITH_EVENT_BUS
8+
from integration.conftest import clean_bucket
9+
from integration.helpers.base_test import BaseTest
10+
from integration.helpers.resource import current_region_does_not_support
11+
12+
retry_once = retry(
13+
stop=stop_after_attempt(2),
14+
# unittest raises SkipTest for skipping tests
15+
retry=retry_if_exception(lambda e: not isinstance(e, SkipTest)),
16+
)
17+
18+
19+
@skipIf(
20+
current_region_does_not_support([EVENT_RULE_WITH_EVENT_BUS]),
21+
"EVENT_RULE_WITH_EVENT_BUS is not supported in this testing region",
22+
)
23+
class TestConnectorsWithEventRuleToEB(BaseTest):
24+
def tearDown(self):
25+
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
26+
# manually empty the bucket to allow stacks to be deleted successfully.
27+
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
28+
if bucket_name:
29+
clean_bucket(bucket_name, self.client_provider.s3_client)
30+
super().tearDown()
31+
32+
@parameterized.expand(
33+
[
34+
("combination/connector_event_rule_to_eb_default_write",),
35+
("combination/connector_event_rule_to_eb_custom_write",),
36+
]
37+
)
38+
@retry_once
39+
def test_connector_event_rule_eb_by_invoking_a_function(self, template_file_path):
40+
self.skip_using_service_detector(template_file_path)
41+
self.create_and_verify_stack(template_file_path)
42+
43+
lambda_function_name = self.get_physical_id_by_logical_id("TriggerFunction")
44+
lambda_client = self.client_provider.lambda_client
45+
46+
request_params = {
47+
"FunctionName": lambda_function_name,
48+
"InvocationType": "RequestResponse",
49+
"Payload": "{}",
50+
}
51+
response = lambda_client.invoke(**request_params)
52+
self.assertEqual(response.get("StatusCode"), 200)
53+
self.assertEqual(response.get("FunctionError"), None)

integration/combination/test_function_with_alias.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,42 @@ def test_alias_with_event_sources_get_correct_permissions(self):
160160
function_policy = json.loads(function_policy_str)
161161
self.assertEqual(len(function_policy["Statement"]), len(permission_resources))
162162

163+
def test_function_with_alias_and_layer_version(self):
164+
self.create_and_verify_stack("combination/function_with_alias_all_properties_and_layer_version")
165+
alias_name = "Live"
166+
function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
167+
version_ids = self.get_function_version_by_name(function_name)
168+
self.assertEqual(["1"], version_ids)
169+
170+
alias = self.get_alias(function_name, alias_name)
171+
self.assertEqual("1", alias["FunctionVersion"])
172+
173+
# Changing Description in the LayerVersion should create a new version, and leave the existing version intact
174+
self.set_template_resource_property("MyLayer", "Description", "test123")
175+
self.update_stack()
176+
177+
version_ids = self.get_function_version_by_name(function_name)
178+
self.assertEqual(["1", "2"], version_ids)
179+
180+
alias = self.get_alias(function_name, alias_name)
181+
self.assertEqual("2", alias["FunctionVersion"])
182+
183+
# Changing ContentUri in LayerVersion should create a new version, and leave the existing version intact
184+
self.set_template_resource_property("MyLayer", "ContentUri", self.file_to_s3_uri_map["layer2.zip"]["uri"])
185+
self.update_stack()
186+
187+
version_ids = self.get_function_version_by_name(function_name)
188+
self.assertEqual(["1", "2", "3"], version_ids)
189+
190+
alias = self.get_alias(function_name, alias_name)
191+
self.assertEqual("3", alias["FunctionVersion"])
192+
193+
# Make sure the stack has only One Version & One Alias resource
194+
alias = self.get_stack_resources("AWS::Lambda::Alias")
195+
versions = self.get_stack_resources("AWS::Lambda::Version")
196+
self.assertEqual(len(alias), 1)
197+
self.assertEqual(len(versions), 1)
198+
163199
def get_function_version_by_name(self, function_name):
164200
lambda_client = self.client_provider.lambda_client
165201
versions = lambda_client.list_versions_by_function(FunctionName=function_name)["Versions"]

integration/config/file_to_s3_map.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"type": "s3",
2424
"uri": ""
2525
},
26+
"layer2.zip": {
27+
"type": "s3",
28+
"uri": ""
29+
},
2630
"swagger1.json": {
2731
"type": "s3",
2832
"uri": ""

integration/config/service_names.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
APP_SYNC = "AppSync"
3737
SNS_FILTER_POLICY_SCOPE = "SnsFilterPolicyScope"
3838
LOGS = "Logs"
39+
EVENT_RULE_WITH_EVENT_BUS = "EventRuleWithEventBus"

integration/helpers/file_resources.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"code.zip": {"type": "s3", "uri": ""},
33
"code2.zip": {"type": "s3", "uri": ""},
44
"layer1.zip": {"type": "s3", "uri": ""},
5+
"layer2.zip": {"type": "s3", "uri": ""},
56
"swagger1.json": {"type": "s3", "uri": ""},
67
"swagger2.json": {"type": "s3", "uri": ""},
78
"binary-media.zip": {"type": "s3", "uri": ""},

integration/resources/code/layer2.zip

2.12 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"LogicalResourceId": "MyLambdaFunction",
4+
"ResourceType": "AWS::Lambda::Function"
5+
},
6+
{
7+
"LogicalResourceId": "MyLambdaFunctionRole",
8+
"ResourceType": "AWS::IAM::Role"
9+
},
10+
{
11+
"LogicalResourceId": "MyLambdaFunctionAliasLive",
12+
"ResourceType": "AWS::Lambda::Alias"
13+
},
14+
{
15+
"LogicalResourceId": "MyLambdaFunctionVersion",
16+
"ResourceType": "AWS::Lambda::Version"
17+
},
18+
{
19+
"LogicalResourceId": "MyLayer",
20+
"ResourceType": "AWS::Lambda::LayerVersion"
21+
}
22+
]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"LogicalResourceId": "SuperCoolAPI",
4+
"ResourceType": "AWS::AppSync::GraphQLApi"
5+
},
6+
{
7+
"LogicalResourceId": "SuperCoolAPICloudWatchRole",
8+
"ResourceType": "AWS::IAM::Role"
9+
},
10+
{
11+
"LogicalResourceId": "SuperCoolAPISchema",
12+
"ResourceType": "AWS::AppSync::GraphQLSchema"
13+
},
14+
{
15+
"LogicalResourceId": "SuperCoolAPIQuerygetBook",
16+
"ResourceType": "AWS::AppSync::Resolver"
17+
},
18+
{
19+
"LogicalResourceId": "SuperCoolAPINoneDataSource",
20+
"ResourceType": "AWS::AppSync::DataSource"
21+
},
22+
{
23+
"LogicalResourceId": "SuperCoolAPIprocessQuery",
24+
"ResourceType": "AWS::AppSync::FunctionConfiguration"
25+
},
26+
{
27+
"LogicalResourceId": "SuperCoolAPIMyApiKey",
28+
"ResourceType": "AWS::AppSync::ApiKey"
29+
},
30+
{
31+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPI",
32+
"ResourceType": "AWS::AppSync::GraphQLApi"
33+
},
34+
{
35+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPICloudWatchRole",
36+
"ResourceType": "AWS::IAM::Role"
37+
},
38+
{
39+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPISchema",
40+
"ResourceType": "AWS::AppSync::GraphQLSchema"
41+
},
42+
{
43+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPIQuerygetBook",
44+
"ResourceType": "AWS::AppSync::Resolver"
45+
},
46+
{
47+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPINoneDataSource",
48+
"ResourceType": "AWS::AppSync::DataSource"
49+
},
50+
{
51+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPIprocessQuery",
52+
"ResourceType": "AWS::AppSync::FunctionConfiguration"
53+
},
54+
{
55+
"LogicalResourceId": "IntrospectionDisableSuperCoolAPIMyApiKey",
56+
"ResourceType": "AWS::AppSync::ApiKey"
57+
}
58+
]

0 commit comments

Comments
 (0)