Skip to content

Commit d39650f

Browse files
Merge branch 'release-v1.52.0'
2 parents c56bded + 9cf520f commit d39650f

File tree

207 files changed

+18121
-111
lines changed

Some content is hidden

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

207 files changed

+18121
-111
lines changed

.github/workflows/pr-labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
github-token: ${{secrets.GITHUB_TOKEN}}
1515
script: |
16-
const maintainers = ['jfuss', 'c2tarun', 'hoffa', 'awood45', 'CoshUS', 'aahung', 'hawflau', 'mndeveci', 'ssenchenko', 'wchengru', 'mingkun2020', 'qingchm', 'moelasmar', 'xazhao', 'mildaniel', 'marekaiv', 'torresxb1']
16+
const maintainers = ['jfuss', 'hoffa', 'awood45', 'aahung', 'hawflau', 'mndeveci', 'ssenchenko', 'qingchm', 'moelasmar', 'xazhao', 'mildaniel', 'marekaiv', 'torresxb1', 'lucashuy', 'hnnasit', 'sriram-mv']
1717
if (maintainers.includes(context.payload.sender.login)) {
1818
github.rest.issues.addLabels({
1919
issue_number: context.issue.number,

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,7 @@ venv.bak/
113113
.vscode
114114

115115
# PyCharm
116-
.idea
116+
.idea
117+
118+
# Companion stack config
119+
integration/config/file_to_s3_map_modified.json

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include requirements/dev.txt
44
recursive-include samtranslator/validator/sam_schema *.json
55
include samtranslator/policy_templates_data/policy_templates.json
66
include samtranslator/policy_templates_data/schema.json
7+
include samtranslator/model/connector_profiles/profiles.json
78
include README.md
89
include THIRD_PARTY_LICENSES
910

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ init:
66
pip install -e '.[dev]'
77

88
test:
9-
pytest --cov samtranslator --cov-report term-missing --cov-fail-under 95 -n auto tests/*
9+
AWS_DEFAULT_REGION=us-east-1 pytest --cov samtranslator --cov-report term-missing --cov-fail-under 95 -n auto tests/*
1010

1111
test-fast:
1212
pytest -x --cov samtranslator --cov-report term-missing --cov-fail-under 95 -n auto tests/*

README.md

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
1-
<p align="center">
2-
</p>
3-
41
# AWS Serverless Application Model (AWS SAM)
52

6-
![Apache-2.0](https://img.shields.io/github/license/aws/serverless-application-model.svg)
7-
![SAM_CLI release](https://img.shields.io/github/release/aws/aws-sam-cli.svg?label=CLI%20Version)
3+
[![Build status](https://ci.appveyor.com/api/projects/status/qlm7sj35nu9o12jc/branch/develop?svg=true)](https://ci.appveyor.com/project/AWSSAMCLI/serverless-application-model/branch/develop)
84
[![codecov](https://codecov.io/gh/aws/serverless-application-model/branch/master/graphs/badge.svg?style=flat)](https://codecov.io/gh/aws/serverless-application-model)
5+
[![PyPI](https://img.shields.io/pypi/v/aws-sam-translator?label=PyPI)](https://pypi.org/project/aws-sam-translator/)
6+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aws-sam-translator)](https://pypi.org/project/aws-sam-translator/)
7+
8+
The [AWS Serverless Application Model](https://aws.amazon.com/serverless/sam/) (SAM) is an open-source framework for building serverless applications.
99

10-
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications.
1110
It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
1211
With just a few lines of configuration, you can define the application you want and model it.
1312

14-
[![Getting Started with AWS SAM](./docs/get-started-youtube.png)](https://www.youtube.com/watch?v=QBBewrKR1qg)
15-
1613
## Recent blogposts and workshops
1714

18-
* **Develop Node projects with SAM CLI using esbuild (Beta)** - and use SAM Accelerate on Typescript projects. [Read blogpost here](https://s12d.com/5Aa6u0o7)
19-
20-
* **Speed up development with SAM Accelerate (Beta)** - quickly test your changes in the cloud. [Read blogpost here](https://s12d.com/WeMib4nf)
21-
22-
* **Getting started with CI/CD? SAM pipelines can help you get started** - [This workshop](https://s12d.com/_JQ48d5T) walks you through the basics
23-
15+
* **Develop Node projects with SAM CLI using esbuild (Beta)** - And use SAM Accelerate on TypeScript projects. [Read blogpost here](https://s12d.com/5Aa6u0o7).
16+
* **Speed up development with SAM Accelerate (Beta)** - Quickly test your changes in the cloud. [Read blogpost here](https://s12d.com/WeMib4nf).
17+
* **Getting started with CI/CD? SAM pipelines can help you get started** - [This workshop](https://s12d.com/_JQ48d5T) walks you through the basics.
2418
* **Get started with Serverless Application development using SAM CLI** - [This workshop](https://s12d.com/Tq9ZE-Br) walks you through the basics.
2519

26-
## Get Started
20+
## Get started
2721

28-
To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution
22+
To get started with building SAM-based applications, use the [AWS SAM CLI](https://github.com/aws/aws-sam-cli). SAM CLI provides a Lambda-like execution
2923
environment that lets you locally build, test, debug, and deploy applications defined by SAM templates.
3024

3125
* [Install SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
32-
* [Build & Deploy a "Hello World" Web App](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html)
33-
* [Install AWS Toolkit](https://aws.amazon.com/getting-started/tools-sdks/#IDE_and_IDE_Toolkits) to use SAM with your favorite IDEs.
26+
* [Build & deploy a "hello world" web app](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html)
27+
* [Install AWS Toolkit](https://aws.amazon.com/getting-started/tools-sdks/#IDE_and_IDE_Toolkits) to use SAM with your favorite IDEs
3428

35-
36-
**Next Steps:** Learn to build a more complex serverless application.
29+
**Next steps:** Learn to build a more complex serverless application.
3730
* [Extract text from images and store in a database](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-example-s3.html) using Amazon S3 and Amazon Rekognition services.
3831
* [Detect when records are added to a database](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-example-ddb.html) using Amazon DynamoDB database and asynchronous stream processing.
32+
* Watch the [Mastering the AWS Serverless Application Model](https://www.youtube.com/watch?v=QBBewrKR1qg) AWS Online Tech Talk.
3933

40-
41-
**Detailed References:** Explains SAM commands and usage in depth.
42-
* [CLI Commands](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-command-reference.html)
43-
* [SAM Template Specification](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html)
44-
* [Policy Templates](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html)
34+
**Detailed references:** Explains SAM commands and usage in depth.
35+
* [CLI commands](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-command-reference.html)
36+
* [SAM template specification](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html)
37+
* [Policy templates](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html)
4538

4639
## Why SAM
4740

@@ -60,7 +53,7 @@ environment that lets you locally build, test, debug, and deploy applications de
6053

6154
+ **Extension of AWS CloudFormation**\. Because SAM is an extension of AWS CloudFormation, you get the reliable deployment capabilities of AWS CloudFormation\. You can define resources by using CloudFormation in your SAM template\. Also, you can use the full suite of resources, intrinsic functions, and other template features that are available in CloudFormation\.
6255

63-
## What is this GitHub repository? 💻
56+
## What is this GitHub repository?
6457

6558
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of example applications.
6659
In the words of SAM developers:
@@ -77,7 +70,7 @@ more about what it was like contributing to SAM.
7770

7871
Depending on your interest and skill, you can help build the different parts of the SAM project;
7972

80-
**Enhance the SAM Specification**
73+
**Enhance the SAM specification**
8174

8275
Make pull requests, report bugs, and share ideas to improve the full SAM template specification.
8376
Source code is located on GitHub at [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model).
@@ -90,12 +83,12 @@ Add new commands or enhance existing ones, report bugs, or request new features
9083
Source code is located on GitHub at [awslabs/aws-sam-cli](https://github.com/awslabs/aws-sam-cli). Read the [SAM CLI Contributing Guide](https://github.com/awslabs/aws-sam-cli/blob/develop/CONTRIBUTING.md) to
9184
get started.
9285

93-
**Update SAM Developer Guide**
86+
**Update SAM developer guide**
9487

9588
[SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/index.html) provides comprehensive getting started guide and reference documentation.
9689
Source code is located on GitHub at [awsdocs/aws-sam-developer-guide](https://github.com/awsdocs/aws-sam-developer-guide).
9790
Read the [SAM Documentation Contribution Guide](https://github.com/awsdocs/aws-sam-developer-guide/blob/master/CONTRIBUTING.md) to get
9891
started.
9992

100-
### Join the SAM Community on Slack
101-
[Join the SAM developers channel (#samdev)](https://join.slack.com/t/awsdevelopers/shared_invite/zt-idww18e8-Z1kXhI7GNuDewkweCF3YjA) on Slack to collaborate with fellow community members and the AWS SAM team.
93+
### Join the SAM community on Slack
94+
[Join the `#samdev` channel](https://join.slack.com/t/awsdevelopers/shared_invite/zt-yryddays-C9fkWrmguDv0h2EEDzCqvw) on Slack to collaborate with fellow community members and the AWS SAM team.

integration/combination/test_api_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_implicit_api_settings(self):
162162

163163
def verify_binary_media_request(self, url, expected_status_code):
164164
headers = {"accept": "image/png"}
165-
response = BaseTest.do_get_request_with_logging(url, headers)
165+
response = self.do_get_request_with_logging(url, headers)
166166

167167
status = response.status_code
168168
expected_file_path = str(Path(self.code_dir, "AWS_logo_RGB.png"))

integration/combination/test_api_with_authorizer_apikey.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def verify_authorized_request(
8080
header_value=None,
8181
):
8282
if not header_key or not header_value:
83-
response = BaseTest.do_get_request_with_logging(url)
83+
response = self.do_get_request_with_logging(url)
8484
else:
8585
headers = {header_key: header_value}
86-
response = BaseTest.do_get_request_with_logging(url, headers)
86+
response = self.do_get_request_with_logging(url, headers)
8787
status = response.status_code
8888
if status != expected_status_code:
8989
raise StatusCodeError(

integration/combination/test_api_with_authorizers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ def verify_authorized_request(
436436
header_value=None,
437437
):
438438
if not header_key or not header_value:
439-
response = BaseTest.do_get_request_with_logging(url)
439+
response = self.do_get_request_with_logging(url)
440440
else:
441441
headers = {header_key: header_value}
442-
response = BaseTest.do_get_request_with_logging(url, headers)
442+
response = self.do_get_request_with_logging(url, headers)
443443
status = response.status_code
444444

445445
if status != expected_status_code:
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
from time import sleep
2+
from parameterized import parameterized
3+
from integration.conftest import clean_bucket
4+
from integration.helpers.base_test import S3_BUCKET_PREFIX, BaseTest
5+
from integration.helpers.resource import generate_suffix
6+
7+
8+
class TestConnectors(BaseTest):
9+
def tearDown(self):
10+
# Some tests will create items in S3 Bucket, which result in stack DELETE_FAILED state
11+
# manually empty the bucket to allow stacks to be deleted successfully.
12+
bucket_name = self.get_physical_id_by_type("AWS::S3::Bucket")
13+
if bucket_name:
14+
clean_bucket(bucket_name, self.client_provider.s3_client)
15+
super().tearDown()
16+
17+
@parameterized.expand(
18+
[
19+
("combination/connector_function_to_function",),
20+
("combination/connector_restapi_to_function",),
21+
("combination/connector_httpapi_to_function",),
22+
("combination/connector_function_to_bucket_read",),
23+
("combination/connector_function_to_bucket_write",),
24+
("combination/connector_function_to_table_read",),
25+
("combination/connector_function_to_table_write",),
26+
("combination/connector_function_to_sfn_read",),
27+
("combination/connector_function_to_sfn_write",),
28+
("combination/connector_function_to_queue_write",),
29+
("combination/connector_function_to_queue_read",),
30+
("combination/connector_function_to_topic_write",),
31+
("combination/connector_function_to_eventbus_write",),
32+
("combination/connector_topic_to_queue_write",),
33+
("combination/connector_event_rule_to_sqs_write",),
34+
("combination/connector_event_rule_to_sns_write",),
35+
("combination/connector_event_rule_to_sfn_write",),
36+
("combination/connector_event_rule_to_eb_default_write",),
37+
("combination/connector_event_rule_to_eb_custom_write",),
38+
("combination/connector_event_rule_to_lambda_write",),
39+
("combination/connector_sqs_to_function",),
40+
("combination/connector_sns_to_function_write",),
41+
("combination/connector_table_to_function_read",),
42+
]
43+
)
44+
def test_connector_by_invoking_a_function(self, template_file_path):
45+
self.skip_using_service_detector(template_file_path)
46+
self.create_and_verify_stack(template_file_path)
47+
48+
lambda_function_name = self.get_physical_id_by_logical_id("TriggerFunction")
49+
lambda_client = self.client_provider.lambda_client
50+
s3_client = self.client_provider.s3_client
51+
52+
request_params = {
53+
"FunctionName": lambda_function_name,
54+
"InvocationType": "RequestResponse",
55+
"Payload": "{}",
56+
}
57+
response = lambda_client.invoke(**request_params)
58+
self.assertEqual(response.get("StatusCode"), 200)
59+
self.assertEqual(response.get("FunctionError"), None)
60+
61+
@parameterized.expand(
62+
[
63+
("combination/connector_sfn_to_table_read",),
64+
("combination/connector_sfn_to_table_write",),
65+
("combination/connector_sfn_to_sqs_write",),
66+
("combination/connector_sfn_to_sns_write",),
67+
("combination/connector_sfn_to_function_write",),
68+
("combination/connector_sfn_to_bucket_write",),
69+
("combination/connector_sfn_to_bucket_read",),
70+
("combination/connector_sfn_to_sfn_async",),
71+
("combination/connector_sfn_to_eb_default_write",),
72+
("combination/connector_sfn_to_eb_custom_write",),
73+
]
74+
)
75+
def test_connector_by_sync_execute_an_state_machine(self, template_file_path):
76+
self.skip_using_service_detector(template_file_path)
77+
self.create_and_verify_stack(template_file_path)
78+
79+
state_machine_arn = self.get_physical_id_by_logical_id("TriggerStateMachine")
80+
sfn_client = self.client_provider.sfn_client
81+
s3_client = self.client_provider.s3_client
82+
83+
response = sfn_client.start_sync_execution(
84+
stateMachineArn=state_machine_arn,
85+
)
86+
# Without permission, it will be "FAILED"
87+
self.assertEqual(response.get("status"), "SUCCEEDED")
88+
89+
@parameterized.expand(
90+
[
91+
("combination/connector_sfn_to_sfn_sync",),
92+
]
93+
)
94+
def test_connector_by_async_execute_an_state_machine(self, template_file_path):
95+
self.skip_using_service_detector(template_file_path)
96+
self.create_and_verify_stack(template_file_path)
97+
98+
state_machine_arn = self.get_physical_id_by_logical_id("TriggerStateMachine")
99+
sfn_client = self.client_provider.sfn_client
100+
101+
response = sfn_client.start_execution(
102+
stateMachineArn=state_machine_arn,
103+
)
104+
execution_arn = response["executionArn"]
105+
106+
status = None
107+
wait_tries = 5
108+
while wait_tries > 0:
109+
response = sfn_client.describe_execution(executionArn=execution_arn)
110+
status = response["status"]
111+
if status == "RUNNING":
112+
wait_tries -= 1
113+
sleep(5)
114+
continue
115+
else:
116+
break
117+
118+
# Without permission, it will be "FAILED"
119+
self.assertEqual(status, "SUCCEEDED")
120+
121+
@parameterized.expand(
122+
[
123+
("combination/connector_bucket_to_function_write",),
124+
]
125+
)
126+
def test_connector_by_execute_a_s3_bucket(self, template_file_path):
127+
self.skip_using_service_detector(template_file_path)
128+
bucket_name = S3_BUCKET_PREFIX + "connector" + generate_suffix()
129+
self.create_and_verify_stack(
130+
template_file_path, [{"ParameterKey": "BucketName", "ParameterValue": bucket_name}]
131+
)
132+
133+
lambda_function_name = self.get_physical_id_by_logical_id("TriggerFunction")
134+
lambda_client = self.client_provider.lambda_client
135+
s3_client = self.client_provider.s3_client
136+
137+
request_params = {
138+
"FunctionName": lambda_function_name,
139+
"InvocationType": "RequestResponse",
140+
"Payload": "{}",
141+
}
142+
response = lambda_client.invoke(**request_params)
143+
self.assertEqual(response.get("StatusCode"), 200)
144+
self.assertEqual(response.get("FunctionError"), None)

integration/config/logger_configurations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ def configure_request_logger(logger):
88
console_handler = logging.StreamHandler()
99
console_handler.setLevel(logging.INFO)
1010
console_handler.setFormatter(
11-
logging.Formatter("%(asctime)s %(message)s | Status: %(status)s | Headers: %(headers)s ")
11+
logging.Formatter(
12+
"\nREQUEST LOG [%(test)s] | Time: %(asctime)s %(message)s | Status: %(status)s | Headers: %(headers)s"
13+
)
1214
)
1315
logger.addHandler(console_handler)
1416
logger.propagate = False

0 commit comments

Comments
 (0)