AWS Serverless Application Model
Developer Guide

Installing the AWS SAM CLI on Windows

The following steps help you to install and configure the required prerequisites for using the AWS SAM CLI on your Windows host:

  1. Create an AWS account.

  2. Configure IAM permissions.

  3. Install the AWS CLI.

  4. Create an Amazon S3 bucket.

  5. Install Docker. Note: Docker is only a prerequisite for testing your application locally.

  6. Install the AWS SAM CLI.

Step 1: Create an AWS Account

If you don't already have an AWS account, see aws.amazon.com and choose Create an AWS Account. For detailed instructions, see Create and Activate an AWS Account.

Step 2: Create an IAM User with Administrator Permissions

If you don't already have an IAM user with administrator permissions, see Creating Your First IAM Admin User and Group in the IAM User Guide.

Step 3: Install and Configure the AWS CLI

If you don't already have the AWS CLI installed, this step shows you how to install and configure it. You can check whether you have the AWS CLI installed by executing aws --version at a command line.

This section has two substeps: a) Install the AWS CLI using an MSI installation package, and b) Configure the AWS CLI to use your credentials, default AWS Region, and desired output format.

Step 3a: Install the AWS CLI

We recommend that you use one of the MSI installation packages. These offer a familiar and convenient way to install the AWS CLI without installing any other prerequisites.

Installing the AWS CLI using an MSI installation package is supported on Microsoft Windows XP or later. For alternative installation options, see Installing the AWS CLI.

To install the AWS CLI using the MSI installer

  1. Download the appropriate MSI installer.

  2. Run the downloaded MSI installer or the setup file.

  3. Follow the onscreen instructions.

By default, the CLI installs to C:\Program Files\Amazon\AWSCLI (64-bit version) or C:\Program Files (x86)\Amazon\AWSCLI (32-bit version). To confirm the installation, use the aws --version command at a command line.

Step 3b: Configure the AWS CLI

After you've verified installing the AWS CLI, you can configure it with your credentials, default AWS Region, and desired output format. To do this, you first create the necessary access keys by following these steps:

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.

  2. In the navigation pane, choose Users.

  3. Choose the name of the user whose access keys you want to create, and then choose the Security credentials tab.

  4. In the Access keys section, choose Create access key.

  5. To view the new access key pair, choose Show. You won't have access to the secret access key again after this dialog box closes. Your credentials look something like this:

    • Access key ID: AKIAIOSFODNN7EXAMPLE

    • Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

  6. To download the key pair, choose Download .csv file. Store the keys in a secure location. You won't have access to the secret access key again after this dialog box closes.

    Keep the keys confidential in order to protect your AWS account, and never email them. Don't share them outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your secret key.

  7. After you download the .csv file, choose Close. When you create an access key, the key pair is active by default, and you can use the pair right away.

Configure the AWS CLI with the access keys that you just created by executing the following command:

aws configure

When you're prompted, replace the following examples with your access keys:

 
 AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE                         # Enter your access key
 AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY # Enter your secret key
 Default region name [None]: us-east-1                                  # Example regions: us-east-1, ap-east-1, eu-central-1, sa-east-1
 Default output format [None]: json                                     # Or 'text'
            

Additional configuration options are available in configuring the AWS CLI.

Step 4: Create an Amazon S3 Bucket

AWS SAM uses an Amazon S3 bucket in your AWS account as a repository to store deployment artifacts. To use the package and deployment functionality of AWS SAM, you must have an Amazon S3 bucket in the Region that you're working in.

If you need to create an Amazon S3 bucket, you can run the following command:

aws s3 mb s3://bucketname --region region # Example regions: us-east-1, ap-east-1, eu-central-1, sa-east-1

You should see the following output for a successfully created Amazon S3 bucket:

 
 make_bucket: bucketname
        

Remember to keep track of your Amazon S3 bucket name because you need it to package your serverless application.

Step 5: Install Docker

Note

Docker is only a prerequisite for testing your application locally and building deployment packages using the --use-container flag. You can skip this section or install Docker at a later time if you don't plan to use these features initially.

Docker is an application that runs containers on your Linux machines. AWS SAM provides a local environment that's similar to AWS Lambda to use as a Docker container. You can use this container to build, test, and debug your serverless applications.

You must have Docker installed and working to be able to run serverless projects and functions locally with the AWS SAM CLI. The AWS SAM CLI uses the DOCKER_HOST environment variable to contact the Docker daemon. The following steps describe how to install, configure, and verify a Docker installation to work with the AWS SAM CLI.

  1. Install Docker.

    Docker Desktop supports the most recent Windows operating system. For legacy versions of Windows, the Docker Toolbox is available. Choose your version of Windows for the correct Docker installation steps:

  2. Configure your shared drives.

    The AWS SAM CLI requires that the project directory, or any parent directory, is listed in a shared drive. Choose your version of Windows below for the correct shared drive instructions:

  3. Verify the installation.

    After Docker is installed, verify that it's working. Also confirm that you can run Docker commands from the AWS SAM CLI (for example, docker ps). You don't need to install, fetch, or pull any containers—the AWS SAM CLI does this automatically as required.

Step 6: Install the AWS SAM CLI

Windows Installer (MSI) files are the package installer files for the Windows operating system.

Follow these steps to install the AWS SAM CLI using the MSI file.

  1. Install the AWS SAM CLI.

    Choose your version of Windows for the correct MSI file:

  2. Verify the installation.

    After completing the installation, verify it by opening a new command prompt or PowerShell prompt. You should be able to invoke sam from the command line.

    sam --version

    You should see output like the following after successful installation of the AWS SAM CLI:

     
     SAM CLI, version 0.19.0
                    

You're now ready to start development.

Next Steps

You're now ready to begin building your own serverless applications using AWS SAM! If you want to start with sample serverless applications, choose one of the following links: