Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,26 @@ The Serverless Application Model Command Line Interface (SAM CLI) is an extensio

To use the SAM CLI, you need the following tools.

* AWS CLI - [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) and [configure it with your AWS credentials].
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
* .NET Core - [Install .NET Core](https://www.microsoft.com/net/download)
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)

The SAM CLI uses an Amazon S3 bucket to store your application's deployment artifacts. If you don't have a bucket suitable for this purpose, create one. Replace `BUCKET_NAME` in the commands in this section with a unique bucket name.
To build and deploy your application for the first time, run the following in your shell:

```bash
{{ cookiecutter.project_name }}$ aws s3 mb s3://BUCKET_NAME
sam build
sam deploy --guided
```

To prepare the application for deployment, use the `sam package` command.
The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:

```bash
{{ cookiecutter.project_name }}$ sam package \
--output-template-file packaged.yaml \
--s3-bucket BUCKET_NAME
```

The SAM CLI creates deployment packages, uploads them to the S3 bucket, and creates a new version of the template that refers to the artifacts in the bucket.
* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
* **AWS Region**: The AWS region you want to deploy your app to.
* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.

To deploy the application, use the `sam deploy` command.

```bash
{{ cookiecutter.project_name }}$ sam deploy \
--template-file packaged.yaml \
--stack-name {{ cookiecutter.project_name }} \
--capabilities CAPABILITY_IAM
```

After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:

```bash
{{ cookiecutter.project_name }}$ aws cloudformation describe-stacks \
--stack-name {{ cookiecutter.project_name }} \
--query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \
--output table
```
You can find your API Gateway Endpoint URL in the output values displayed after deployment.

## Use the SAM CLI to build and test locally

Expand Down Expand Up @@ -123,11 +105,10 @@ Tests are defined in the `test` folder in this project.

## Cleanup

To delete the sample application and the bucket that you created, use the AWS CLI.
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:

```bash
{{ cookiecutter.project_name }}$ aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name }}
{{ cookiecutter.project_name }}$ aws s3 rb s3://BUCKET_NAME
aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name }}
```

## Resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,38 +77,21 @@ AWS Lambda Python runtime requires a flat folder with all dependencies including
...
```

First and foremost, we need a `S3 bucket` where we can upload our Lambda functions packaged as ZIP before we deploy anything - If you don't have a S3 bucket to store code artifacts then this is a good time to create one:
To deploy your application for the first time, run the following in your shell:

```bash
aws s3 mb s3://BUCKET_NAME
sam deploy --guided
```

Next, run the following command to package our Lambda function to S3:
The command will package and deploy your application to AWS, with a series of prompts:

```bash
sam package \
--output-template-file packaged.yaml \
--s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME
```

Next, the following command will create a Cloudformation Stack and deploy your SAM resources.

```bash
sam deploy \
--template-file packaged.yaml \
--stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \
--capabilities CAPABILITY_IAM
```

> **See [Serverless Application Model (SAM) HOWTO Guide](https://github.com/awslabs/serverless-application-model/blob/master/HOWTO.md) for more details in how to get started.**
* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
* **AWS Region**: The AWS region you want to deploy your app to.
* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.

After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:

```bash
aws cloudformation describe-stacks \
--stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \
--query 'Stacks[].Outputs'
```
You can find your API Gateway Endpoint URL in the output values displayed after deployment.

### Testing

Expand Down Expand Up @@ -153,25 +136,6 @@ If it's already installed, run the following command to ensure it's the latest v
```shell
choco upgrade golang
```
## AWS CLI commands

AWS CLI commands to package, deploy and describe outputs defined within the cloudformation stack:

```bash
sam package \
--template-file template.yaml \
--output-template-file packaged.yaml \
--s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME

sam deploy \
--template-file packaged.yaml \
--stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} \
--capabilities CAPABILITY_IAM \
--parameter-overrides MyParameterSample=MySampleValue

aws cloudformation describe-stacks \
--stack-name {{ cookiecutter.project_name.lower().replace(' ', '-') }} --query 'Stacks[].Outputs'
```

## Bringing to the next level

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,26 @@ The Serverless Application Model Command Line Interface (SAM CLI) is an extensio

To use the SAM CLI, you need the following tools.

* AWS CLI - [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) and [configure it with your AWS credentials].
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
* Java8 - [Install the Java SE Development Kit 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)

The SAM CLI uses an Amazon S3 bucket to store your application's deployment artifacts. If you don't have a bucket suitable for this purpose, create one. Replace `BUCKET_NAME` in the commands in this section with a unique bucket name.
To build and deploy your application for the first time, run the following in your shell:

```bash
{{ cookiecutter.project_name }}$ aws s3 mb s3://BUCKET_NAME
sam build
sam deploy --guided
```

To prepare the application for deployment, use the `sam package` command.
The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:

```bash
{{ cookiecutter.project_name }}$ sam package \
--output-template-file packaged.yaml \
--s3-bucket BUCKET_NAME
```

The SAM CLI creates deployment packages, uploads them to the S3 bucket, and creates a new version of the template that refers to the artifacts in the bucket.
* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
* **AWS Region**: The AWS region you want to deploy your app to.
* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.

To deploy the application, use the `sam deploy` command.

```bash
{{ cookiecutter.project_name }}$ sam deploy \
--template-file packaged.yaml \
--stack-name {{ cookiecutter.project_name }} \
--capabilities CAPABILITY_IAM
```

After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:

```bash
{{ cookiecutter.project_name }}$ aws cloudformation describe-stacks \
--stack-name {{ cookiecutter.project_name }} \
--query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \
--output table
```
You can find your API Gateway Endpoint URL in the output values displayed after deployment.

## Use the SAM CLI to build and test locally

Expand Down Expand Up @@ -124,11 +106,10 @@ HelloWorldFunction$ gradle test

## Cleanup

To delete the sample application and the bucket that you created, use the AWS CLI.
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:

```bash
{{ cookiecutter.project_name }}$ aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name }}
{{ cookiecutter.project_name }}$ aws s3 rb s3://BUCKET_NAME
aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name }}
```

## Resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,27 @@ The Serverless Application Model Command Line Interface (SAM CLI) is an extensio

To use the SAM CLI, you need the following tools.

* AWS CLI - [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) and [configure it with your AWS credentials].
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
* Java8 - [Install the Java SE Development Kit 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
* Maven - [Install Maven](https://maven.apache.org/install.html)
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)

The SAM CLI uses an Amazon S3 bucket to store your application's deployment artifacts. If you don't have a bucket suitable for this purpose, create one. Replace `BUCKET_NAME` in the commands in this section with a unique bucket name.
To build and deploy your application for the first time, run the following in your shell:

```bash
{{ cookiecutter.project_name }}$ aws s3 mb s3://BUCKET_NAME
sam build
sam deploy --guided
```

To prepare the application for deployment, use the `sam package` command.
The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:

```bash
{{ cookiecutter.project_name }}$ sam package \
--output-template-file packaged.yaml \
--s3-bucket BUCKET_NAME
```

The SAM CLI creates deployment packages, uploads them to the S3 bucket, and creates a new version of the template that refers to the artifacts in the bucket.
* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
* **AWS Region**: The AWS region you want to deploy your app to.
* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modified IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.

To deploy the application, use the `sam deploy` command.

```bash
{{ cookiecutter.project_name }}$ sam deploy \
--template-file packaged.yaml \
--stack-name {{ cookiecutter.project_name }} \
--capabilities CAPABILITY_IAM
```

After deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:

```bash
{{ cookiecutter.project_name }}$ aws cloudformation describe-stacks \
--stack-name {{ cookiecutter.project_name }} \
--query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \
--output table
```
You can find your API Gateway Endpoint URL in the output values displayed after deployment.

## Use the SAM CLI to build and test locally

Expand Down Expand Up @@ -125,11 +107,10 @@ HelloWorldFunction$ mvn test

## Cleanup

To delete the sample application and the bucket that you created, use the AWS CLI.
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:

```bash
{{ cookiecutter.project_name }}$ aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name }}
{{ cookiecutter.project_name }}$ aws s3 rb s3://BUCKET_NAME
aws cloudformation delete-stack --stack-name {{ cookiecutter.project_name }}
```

## Resources
Expand Down
Loading