You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
about: Suggest an idea/feature/enhancement for the SAM Translator
4
+
title: ''
5
+
labels: ''
6
+
assignees: ''
7
+
8
+
---
9
+
10
+
<!-- Make sure we don't have an existing Issue for that feature request (open or closed). -->
11
+
12
+
### Describe your idea/feature/enhancement
13
+
14
+
Provide a clear description.
15
+
16
+
Ex: I wish the SAM Translator would [...]
17
+
18
+
### Proposal
19
+
20
+
Add details on how to add this to the product.
21
+
22
+
Things to consider:
23
+
[] The [SAM documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html) will need to be updated
These tests run SAM against AWS services by translating SAM templates, deploying them to Cloud Formation and verifying the resulting objects.
4
+
5
+
They must run successfully under Python 2 and 3.
6
+
7
+
## Run the tests
8
+
9
+
### Prerequisites
10
+
11
+
#### User and rights
12
+
13
+
An Internet connection and an active AWS account are required to run the tests as they will interact with AWS services (most notably Cloud Formation) to create and update objects (Stacks, APIs, ...).
14
+
15
+
AWS credentials must be configured either through a [credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) or [environment variables](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html)
16
+
17
+
The user running the tests must have the following roles:
18
+
19
+
```
20
+
AmazonSQSFullAccess
21
+
AmazonSNSFullAccess
22
+
AmazonAPIGatewayAdministrator
23
+
AWSKeyManagementServiceFullAccess
24
+
AWSStepFunctionsFullAccess
25
+
```
26
+
27
+
If you plan on running the full tests suite, ensure that the user credentials you are running the tests with have a timeout of at least 30 minutes as the full suite can take more than 20 minutes to execute.
28
+
29
+
#### Initialize the development environment
30
+
31
+
If you haven't done so already, run the following command in a terminal at the root of the repository to initialize the development environment:
*We don't measure coverage for integration tests.*
74
+
75
+
## Write a test
76
+
77
+
1. Add your test templates to the `integration/resources/templates` single or combination folder.
78
+
2. Write an expected json file for all the expected resources and add it to the `integration/resources/expected`.
79
+
3. (Optional) Add the resource files (zip, json, etc.) to `integration/resources/code` and update the dictionaries in `integration/helpers/file_resources.py`.
80
+
4. Write and add your python test code to the `integration` single or combination folder.
81
+
5. Run it!
82
+
83
+
## Skip tests for a specific service in a region
84
+
85
+
1. Add the service you want to skip to the `integration/config/region_service_exclusion.yaml` under the region
86
+
2. Add the @skipIf decorator to the test with the service name, take 'XRay' for example:
87
+
```@skipIf(current_region_does_not_support('XRay'), 'XRay is not supported in this testing region')```
88
+
89
+
## Directory structure
90
+
91
+
### Helpers
92
+
93
+
Common classes and tools used by tests.
94
+
95
+
```
96
+
+-- helpers/
97
+
| +-- deployer Tools to deploy to Cloud Formation
98
+
| +-- base_test.py Common class from which all test classes inherit
99
+
| +-- file_resources.py Files to upload to S3
100
+
| +-- resource.py Helper functions to manipulate resources
101
+
| +-- template.py Helper functions to translate the template
102
+
```
103
+
104
+
`base_test.py` contains `setUpClass` and `tearDownClass` methods to respectively upload and clean the `file_resources.py` resources (upload the files to a new S3 bucket, empty and delete this bucket).
105
+
106
+
### Resources
107
+
108
+
File resources used by tests.
109
+
110
+
```
111
+
+-- resources
112
+
| +-- code Files to upload to S3
113
+
| +-- expected Files describing the expected created resources
114
+
| +-- templates Source SAM templates to translate and deploy
115
+
```
116
+
117
+
The matching *expected* and *template* files should have the same name.
118
+
119
+
For example, the `test_basic_api` test in the class `tests_integ/single/test_basic_api.py` takes `templates/single/basic_api.yaml` SAM template as input and verifies its result against `expected/single/basic_api.json`.
120
+
121
+
### Single
122
+
123
+
Basic tests which interact with only one service should be put here.
124
+
125
+
### Combination
126
+
127
+
Tests which interact with multiple services should be put there.
128
+
129
+
### Tmp
130
+
131
+
This directory is created on the first run and contains temporary and intermediary files used by the tests: sam templates with substituted variable values, translated temporary cloud formation templates, ...
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications.
10
-
It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
10
+
The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications.
11
+
It provides shorthand syntax to express functions, APIs, databases, and event source mappings.
11
12
With just a few lines of configuration, you can define the application you want and model it.
12
13
13
14
[](https://www.youtube.com/watch?v=1dzihtC5LJ0)
14
15
15
16
## Get Started
16
17
17
-
To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution
18
+
To get started with building SAM-based applications, use the SAM CLI. SAM CLI provides a Lambda-like execution
18
19
environment that lets you locally build, test, debug, and deploy applications defined by SAM templates.
19
20
20
21
*[Install SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
@@ -35,14 +36,14 @@ environment that lets you locally build, test, debug, and deploy applications de
35
36
## Why SAM
36
37
37
38
+**Single\-deployment configuration**\. SAM makes it easy to organize related components and resources, and operate on a single stack\. You can use SAM to share configuration \(such as memory and timeouts\) between resources, and deploy all related resources together as a single, versioned entity\.
38
-
39
+
39
40
+**Local debugging and testing**\. Use SAM CLI to locally build, test, and debug SAM applications on a Lambda-like execution environment. It tightens the development loop by helping you find & troubleshoot issues locally that you might otherwise identify only after deploying to the cloud.
40
41
41
42
+**Deep integration with development tools**. You can use SAM with a suite of tools you love and use.
+**Built\-in best practices**\. You can use SAM to define and deploy your infrastructure as configuration. This makes it possible for you to use and enforce best practices through code reviews. Also, with a few lines of configuration, you can enable safe deployments through CodeDeploy, and can enable tracing using AWS X\-Ray\.
@@ -51,40 +52,40 @@ environment that lets you locally build, test, debug, and deploy applications de
51
52
52
53
## What is this Github repository? 💻
53
54
54
-
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of examples applications.
55
+
This GitHub repository contains the SAM Specification, the Python code that translates SAM templates into AWS CloudFormation stacks and lots of examples applications.
55
56
In the words of SAM developers:
56
57
57
-
> SAM Translator is the Python code that deploys SAM templates via AWS CloudFormation. Source code is high quality (95% unit test coverage),
58
-
with tons of tests to ensure your changes don't break compatibility. Change the code, run the tests, and if they pass, you should be good to go!
58
+
> SAM Translator is the Python code that deploys SAM templates via AWS CloudFormation. Source code is high quality (95% unit test coverage),
59
+
with tons of tests to ensure your changes don't break compatibility. Change the code, run the tests, and if they pass, you should be good to go!
59
60
Clone it and run `make pr`!
60
61
61
62
## Contribute to SAM
62
63
63
-
We love our contributors ❤️ We have over 100 contributors who have built various parts of the product.
64
+
We love our contributors ❤️ We have over 100 contributors who have built various parts of the product.
64
65
Read this [testimonial from @ndobryanskyy](https://www.lohika.com/aws-sam-my-exciting-first-open-source-experience/) to learn
65
-
more about what it was like contributing to SAM.
66
+
more about what it was like contributing to SAM.
66
67
67
-
Depending on your interest and skill, you can help build the different parts of the SAM project;
68
+
Depending on your interest and skill, you can help build the different parts of the SAM project;
68
69
69
70
**Enhance the SAM Specification**
70
71
71
72
Make pull requests, report bugs, and share ideas to improve the full SAM template specification.
72
-
Source code is located on Github at [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model).
73
+
Source code is located on Github at [awslabs/serverless-application-model](https://github.com/awslabs/serverless-application-model).
73
74
Read the [SAM Specification Contributing Guide](https://github.com/awslabs/serverless-application-model/blob/master/CONTRIBUTING.md)
74
75
to get started.
75
-
76
+
76
77
**Strengthen SAM CLI**
77
78
78
79
Add new commands or enhance existing ones, report bugs, or request new features for the SAM CLI.
79
-
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
80
-
get started.
80
+
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
81
+
get started.
81
82
82
83
**Update SAM Developer Guide**
83
84
84
85
[SAM Developer Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/index.html) provides comprehensive getting started guide and reference documentation.
85
86
Source code is located on Github at [awsdocs/aws-sam-developer-guide](https://github.com/awsdocs/aws-sam-developer-guide).
86
87
Read the [SAM Documentation Contribution Guide](https://github.com/awsdocs/aws-sam-developer-guide/blob/master/CONTRIBUTING.md) to get
87
-
started.
88
+
started.
88
89
89
90
### Join the SAM Community on Slack
90
91
[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.
0 commit comments