Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ddfe1f4
refactor: add support for Python 3 (#490)
brettstack Jun 28, 2018
a716175
docs: minor improvements to HOWTO.md (#473)
quinnypig Jun 29, 2018
ca0fe86
docs: minor grammatical corrections (#482)
andrew-dixon Jun 29, 2018
d9c64d0
chore: merge pull request #496 from awslabs/master
brettstack Jul 3, 2018
3765857
Updating readme.md for the schedule example as a follow-up to PR 482 …
dhruvsood Jul 9, 2018
f654eaf
docs: remove unnecessary files from api-gateway-authorizer-python (#505)
Jul 11, 2018
f80f843
fix: allow scalar DependsOn values of S3 buckets (#508)
txase Jul 15, 2018
355c26b
docs: added remark about CodeUri property on Globals (#498)
glnds Jul 16, 2018
8c837b0
docs: small fix, grammar and readability improvement in globals.rst (…
Jul 16, 2018
9129685
docs: formatted example code (#506)
eliranmal Jul 16, 2018
725f63b
fix: add DeleteObject to S3CrudPolicy (#453)
bmalnad Jul 18, 2018
7cb4396
docs: fix a typo in CONTRIBUTING.md (#529)
nachobot Aug 1, 2018
540902c
docs: fix simple-mobile-backend example app (#536)
jlhood Aug 2, 2018
6a70a01
fix: removed DynamoDB dependency in sample app (#515)
hsbakshi Aug 2, 2018
1f17282
docs: remove redundant/unused schema files in docs/ (#484)
brettstack Aug 2, 2018
79bd83d
feat: add AWSSecretsManagerGetSecretValuePolicy (#539)
willtong1234 Aug 7, 2018
200898a
feat(plugins): added DefaultDefinitionBody plugin (#541)
brettstack Aug 8, 2018
b02e04c
docs: fix grammar in globals.rst (#542)
keetonian Aug 9, 2018
95c27e6
fix: fix Resource for CodePipelineLambdaExecutionPolicy policy templa…
Tanbouz Aug 10, 2018
43fae91
docs: update reference for AWS SAM CLI (#545)
jfuss Aug 10, 2018
95173aa
fix: remove JSON Schema validation warning (#549)
brettstack Aug 16, 2018
176ec88
docs: add hello world example with VPCConfig (#551)
heitorlessa Aug 20, 2018
2a8cac5
docs: update example apps to use policy templates and parameters (#554)
brettstack Sep 4, 2018
fdf12e5
Fix parameter definition in example apps template (#560)
honglu Sep 5, 2018
6857fb5
docs: update globals example to use yaml code style (#555)
keetonian Sep 8, 2018
4637616
docs: update requirements to fix travis build (#570)
keetonian Sep 10, 2018
435874a
docs: update API EndpointConfiguration options (#569)
keetonian Sep 11, 2018
24003bf
feat: expose skill ID for event source validation with Alexa skills (…
breedloj Sep 11, 2018
e15cb72
docs: change license for AWS Greengrass examples (#575)
sushantAtAws Sep 11, 2018
1db3391
ci: update tests to use full path for files (#576)
keetonian Sep 12, 2018
47c09ac
ci: patch dependency on boto3 region_name param (#577)
keetonian Sep 12, 2018
65ab427
Added RekognitionDetectOnlyPolicy to SAM (#571)
RobRoseKnows Sep 12, 2018
a86d085
ci: update test_validator.py (#578)
keetonian Sep 13, 2018
ba81aca
Revert "docs: remove reference to InlineCode which is unreleased"
keetonian Sep 25, 2018
edbcc0d
fix: conditionally install enum34 based on python version (#582)
sriram-mv Sep 18, 2018
c487006
chore: merge pull request #594 from awslabs/1.7.0-patch-release
keetonian Sep 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Here are some questions that you should answer in your plan:

- **How do developers work around this problem today?**

Example: Manually click through every step on the website while refering to
Example: Manually click through every step on the website while referring to
"How To" resources on the internet.

- **Describe your proposed solution?**
Expand Down
16 changes: 8 additions & 8 deletions HOWTO.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# How to create serverless applications using AWS SAM
AWS Serverless Application Model (AWS SAM) allows you to easily create and
The AWS Serverless Application Model (AWS SAM) allows you to easily create and
manage resources used in your serverless application using AWS CloudFormation.
You can define your serverless application as a SAM template - a JSON or YAML
configuration file that describes Lambda function, API endpoints and
other resources in your application. Using nifty commands, you upload this
template to CloudFormation which creates all the individual resources and
other resources in your application. Using a variety of [nifty commands](https://github.com/awslabs/aws-sam-cli#usage), you upload this
template to CloudFormation, which in turn creates all the individual resources and
groups them into a *CloudFormation Stack* for ease of management.
When you update your SAM template, you will re-deploy the changes to
this stack. AWS CloudFormation will take care of updating the individual
resources for you.


The remainder of document explains how to write SAM templates and
The remainder of this document explains how to write SAM templates and
deploy them via AWS CloudFormation.

## Writing SAM Template
Checkout the [latest specification](versions/2016-10-31.md) for details on how to write a SAM template
Check out the [latest specification](versions/2016-10-31.md) for details on how to write a SAM template

## Packing Artifacts
Before you can deploy a SAM template, you should first upload your Lambda
Expand Down Expand Up @@ -71,7 +71,7 @@ SAM template is deployed to AWS CloudFormation by [creating a changeset](http://
using the SAM template followed by [executing the changeset](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets-execute.html).
Think of a ChangeSet as a diff between your current stack template and the new template that you are deploying. After you create a ChangeSet, you have the opportunity to examine the diff before executing it. Both the AWS Console and AWS CLI provide commands to create and execute a changeset.

Alternatively, you can use `aws cloudformation deploy` CLI command to deploy the SAM template. Under-the-hood it creates and executes a changeset and waits until the deployment completes. It also prints debugging hints when the deployment fails. Run the following command to deploy the packaged template to a stack called `my-new-stack`:
Alternatively, you can use `aws cloudformation deploy` CLI command to deploy the SAM template. Under the hood it creates and executes a changeset and waits until the deployment completes. It also prints debugging hints when the deployment fails. Run the following command to deploy the packaged template to a stack called `my-new-stack`:

```bash
$ aws cloudformation deploy \
Expand All @@ -83,7 +83,7 @@ $ aws cloudformation deploy \
Refer to the [documentation](http://docs.aws.amazon.com/cli/latest/reference/cloudformation/deploy/index.html) for more details.

## Using Intrinsic Functions
CloudFormation provides handy functions you can use to generate values at runtime. These are called [Intrinsic Functions](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html). Since SAM is deployed using CloudFormation, you can use these intrinsic functions within SAM as well. Here are some examples:
CloudFormation provides handy functions that you can use to generate values at runtime. These are called [Intrinsic Functions](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html). Since SAM is deployed using CloudFormation, you can use these intrinsic functions within SAM as well. Here are some examples:

#### Dynamically set S3 location of Lambda function code zip
```YAML
Expand Down Expand Up @@ -136,7 +136,7 @@ Resources:

### Caveats:
#### ImportValue is partially supported
[`ImportValue`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html) allows one stack to refer to value of properties from another stack. ImportValue is supported on most properties, except the very few that SAM needs to parse. Following properties are *not* supported:
[`ImportValue`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html) allows one stack to refer to the value of properties from another stack. ImportValue is supported on most properties, except the very few that SAM needs to parse. The following properties are *not* supported:

- `RestApiId` of `AWS::Serverless::Function`
- `Policies` of `AWS::Serverless::Function`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The SAM specification and implementation are open sourced under the Apache 2.0 l


## Creating a serverless application using SAM
To create a serverless application using SAM, first, you create a SAM template: a JSON or YAML configuration file that describes your Lambda functions, API endpoints and the other resources in your application. Then, you test, upload, and deploy your application using the [SAM Local CLI](https://github.com/awslabs/aws-sam-local). During deployment, SAM automatically translates your application’s specification into CloudFormation syntax, filling in default values for any unspecified properties and determining the appropriate mappings and invocation permissions to setup for any Lambda functions.
To create a serverless application using SAM, first, you create a SAM template: a JSON or YAML configuration file that describes your Lambda functions, API endpoints and the other resources in your application. Then, you test, upload, and deploy your application using the [AWS SAM CLI](https://github.com/awslabs/aws-sam-cli). During deployment, SAM automatically translates your application’s specification into CloudFormation syntax, filling in default values for any unspecified properties and determining the appropriate mappings and invocation permissions to setup for any Lambda functions.

[Read the How-To Guide](HOWTO.md) and see [examples](examples/) to learn how to define & deploy serverless applications using SAM.

Expand Down
26 changes: 17 additions & 9 deletions bin/sam-translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from samtranslator.public.translator import ManagedPolicyLoader
from samtranslator.translator.transform import transform
from samtranslator.yaml_helper import yaml_parse
from samtranslator.model.exceptions import InvalidDocumentException


cli_options = docopt(__doc__)
iam_client = boto3.client('iam')
Expand All @@ -42,15 +44,21 @@ def main():
with open(input_file_path, 'r') as f:
sam_template = yaml_parse(f)

cloud_formation_template = transform(
sam_template, {}, ManagedPolicyLoader(iam_client))
cloud_formation_template_prettified = json.dumps(
cloud_formation_template, indent=2)

with open(output_file_path, 'w') as f:
f.write(cloud_formation_template_prettified)

print('Wrote transformed CloudFormation template to: ' + output_file_path)
try:
cloud_formation_template = transform(
sam_template, {}, ManagedPolicyLoader(iam_client))
cloud_formation_template_prettified = json.dumps(
cloud_formation_template, indent=2)

with open(output_file_path, 'w') as f:
f.write(cloud_formation_template_prettified)

print('Wrote transformed CloudFormation template to: ' + output_file_path)
except InvalidDocumentException as e:
errorMessage = reduce(lambda message, error: message + ' ' + error.message, e.causes, e.message)
print(errorMessage)
errors = map(lambda cause: {'errorMessage': cause.message}, e.causes)
print(errors)


if __name__ == '__main__':
Expand Down
43 changes: 28 additions & 15 deletions docs/globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ In the above example, both ``HelloWorldFunction`` and ``ThumbnailFunction`` will
timeout and index.handler Handler. ``HelloWorldFunction`` adds MESSAGE environment variable in addition to the
inherited TABLE_NAME. ``ThumbnailFunction`` inherits all the Globals properties and adds an API Event source.

Supported Resources
-------------------
Properties of ``AWS::Serverless::Function`` and ``AWS::Serverless::Api`` are only supported in Globals section
presently.
Supported Resources and Properties
----------------------------------
Currently, the following resources and properties are being supported:

.. code:: yaml

Globals:
Function:
# Some properties of AWS::Serverless::Function
# Properties of AWS::Serverless::Function
Handler:
Runtime:
CodeUri:
# Specifying CodeUri on Globals is not yet supported by 'CloudFormation package' https://docs.aws.amazon.com/cli/latest/reference/cloudformation/package.html
CodeUri:
DeadLetterQueue:
Description:
MemorySize:
Expand All @@ -68,7 +68,7 @@ presently.
DeploymentPreference:

Api:
# Some properties of AWS::Serverless::Api
# Properties of AWS::Serverless::Api
# Also works with Implicit APIs
Name:
DefinitionUri:
Expand All @@ -81,6 +81,7 @@ presently.
Cors:

SimpleTable:
# Properties of AWS::Serverless::SimpleTable
SSESpecification

Implicit APIs
Expand Down Expand Up @@ -143,20 +144,19 @@ Runtime of ``MyFunction`` will be set to python3.6

Maps are merged
~~~~~~~~~~~~~~~
*Also called as dictionaries, or key/value pairs*
*Maps are also known as dictionaries or collections of key/value pairs*

Map value in the resource will be **merged** with the map value from Global.
Map entries in the resource will be **merged** with global map entries. In case of duplicates the resource entry will override the global entry.

Example:

Environment variables of ``MyFunction`` will be set to ``{ TABLE_NAME: "resource-table", "NEW_VAR": "hello" }``

.. code:: yaml

Globals:
Function:
Environment:
Variables:
STAGE: Production
TABLE_NAME: global-table

Resources:
Expand All @@ -168,16 +168,24 @@ Environment variables of ``MyFunction`` will be set to ``{ TABLE_NAME: "resource
TABLE_NAME: resource-table
NEW_VAR: hello

In the above example the environment variables of ``MyFunction`` will be set to:

.. code:: json

{
"STAGE": "Production",
"TABLE_NAME": "resource-table",
"NEW_VAR": "hello"
}

Lists are additive
~~~~~~~~~~~~~~~~~~~
*Also called as arrays*
*Lists are also known as arrays*

List values in the resource will be **appended** with the map value from Global.
Global entries will be **prepended** to the list in the resource.

Example:

SecurityGroupIds of VpcConfig will be set to ``["sg-first", "sg-123", "sg-456"]``

.. code:: yaml

Globals:
Expand All @@ -195,3 +203,8 @@ SecurityGroupIds of VpcConfig will be set to ``["sg-first", "sg-123", "sg-456"]`
SecurityGroupIds:
- sg-first

In the above example the Security Group Ids of ``MyFunction``'s VPC Config will be set to:

.. code:: json

[ "sg-123", "sg-456", "sg-first" ]
2 changes: 1 addition & 1 deletion docs/policy_templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ folder.
Policies:
- CloudWatchPutMetricPolicy: {}

.. _policy_templates.json: https://github.com/awslabs/serverless-application-model/blob/develop/docs/policy_templates_data/policy_templates.json
.. _policy_templates.json: https://github.com/awslabs/serverless-application-model/blob/develop/samtranslator/policy_templates_data/policy_templates.json
.. _all_policy_templates.yaml: https://github.com/awslabs/serverless-application-model/blob/develop/examples/2016-10-31/policy_templates/all_policy_templates.yaml
Loading