Packaging SAM Applications

Let's look at the packaging step that is required to deploy SAM applications after the project has been built.

Step 2: Package

Creating a bucket

The next step is to bundle all the files required by each function into separate ZIP archives and upload the results to S3. In order to do that, you will first need an S3 bucket to host your function packages. In continuous delivery jargon, this will be your binary artefact storage. Think of a nice bucket name and then create a new S3 bucket using the following command line (replace BUCKET-NAME with your chosen name):

aws s3 mb s3://BUCKET-NAME

For example, to create a bucket called sam-project-deployment, run the following command:

aws s3 mb s3://sam-project-deployment

S3 was one of the first services AWS launched, way back in March 2006, when they weren’t yet thinking too much about conquering the world. As a result, all bucket names are unique globally, across all accounts. You will not be able to use sam-project-deployment, because that bucket has already been claimed by me. Think of a nice name for your deployment bucket and remember to use it instead of my bucket name when deploying your examples.

You can safely reuse the same binary artefact storage for all your projects, so you do not need to create a separate bucket for each deployment.

Deploying to a specific AWS region

AWS command-line tools, including SAM CLI, allow users to select a specific data center with the --region option. If you want to create resources in a specific region, add --region followed by the AWS data center identifier to the command line. For example, to create a bucket in N. Virginia, use the following command:

aws s3 mb s3://bucket --region us-east-1

You may create your bucket in the terminal provided below:

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy