

# Amazon SAM prerequisites
<a name="prerequisites"></a>

Complete the following prerequisites before installing and using the Amazon Serverless Application Model Command Line Interface (Amazon SAM CLI).

To use the Amazon SAM CLI, you need the following:
+ An Amazon account, Amazon Identity and Access Management (IAM) credentials, and an IAM access key pair.
+ The Amazon Command Line Interface (Amazon CLI) to configure Amazon credentials.

**Topics**
+ [Step 1: Sign up for an Amazon account](#prerequisites-sign-up)
+ [Step 2: Create an IAM user account](#prerequisites-create-user)
+ [Step 3: Create an access key ID and secret access key](#prerequisites-create-keys)
+ [Step 4: Install the Amazon CLI](#prerequisites-install-cli)
+ [Step 5: Use the Amazon CLI to configure Amazon credentials](#prerequisites-configure-credentials)
+ [Step 6: (Optional) Install Amazon Toolkit for VS Code](#prerequisites-install-vscode)
+ [Next steps](#prerequisites-next-steps)

## Step 1: Sign up for an Amazon account
<a name="prerequisites-sign-up"></a>

If you do not have an Amazon Web Services account, use the following procedure to create one.

**To sign up for Amazon Web Services**

1. Open [http://www.amazonaws.cn/](http://www.amazonaws.cn/) and choose **Sign Up**.

1. Follow the on-screen instructions.

## Step 2: Create an IAM user account
<a name="prerequisites-create-user"></a>

### Secure IAM users
<a name="secure-an-admin"></a>

After you sign up for an Amazon Web Services account, safeguard your administrative user by turning on multi-factor authentication (MFA). For instructions, see [Enable a virtual MFA device for an IAM user (console)](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_credentials_mfa_enable_virtual.html#enable-virt-mfa-for-iam-user) in the *IAM User Guide*.

To give other users access to your Amazon Web Services account resources, create IAM users. To secure your IAM users, turn on MFA and only give the IAM users the permissions needed to perform their tasks.

For more information about creating and securing IAM users, see the following topics in the *IAM User Guide*: 
+ [Creating an IAM user in your Amazon Web Services account](https://docs.amazonaws.cn//IAM/latest/UserGuide/id_users_create.html)
+ [Access management for Amazon resources](https://docs.amazonaws.cn/IAM/latest/UserGuide/access.html)
+ [Example IAM identity-based policies](https://docs.amazonaws.cn/IAM/latest/UserGuide/access_policies_examples.html)

## Step 3: Create an access key ID and secret access key
<a name="prerequisites-create-keys"></a>

For CLI access, you need an access key ID and a secret access key. Use temporary credentials instead of long-term access keys when possible. Temporary credentials include an access key ID, a secret access key, and a security token that indicates when the credentials expire. For more information, see [ Using temporary credentials with Amazon resources](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_credentials_temp_use-resources.html) in the *IAM User Guide*.

Users need programmatic access if they want to interact with Amazon outside of the Amazon Web Services Management Console. The Amazon APIs and the Amazon Command Line Interface require access keys. Whenever possible, create temporary credentials that consist of an access key ID, a secret access key, and a security token that indicates when the credentials expire.

To grant users programmatic access, choose one of the following options.


****  

| Which user needs programmatic access? | To | By | 
| --- | --- | --- | 
| IAM | Use short-term credentials to sign programmatic requests to the Amazon CLI or Amazon APIs (directly or by using the Amazon SDKs). | Following the instructions in [Using temporary credentials with Amazon resources](https://docs.amazonaws.cn//IAM/latest/UserGuide/id_credentials_temp_use-resources.html) in the IAM User Guide. | 
| IAM | (Not recommended)Use long-term credentials to sign programmatic requests to the Amazon CLI or Amazon APIs (directly or by using the Amazon SDKs). | Following the instructions in [Managing access keys for IAM users](https://docs.amazonaws.cn//IAM/latest/UserGuide/id_credentials_access-keys.html) in the IAM User Guide. | 

## Step 4: Install the Amazon CLI
<a name="prerequisites-install-cli"></a>

The Amazon CLI is an open source tool that enables you to interact with Amazon Web Services services using commands in your command-line shell. The Amazon SAM CLI requires the Amazon CLI for activities such as configuring credentials. To learn more about the Amazon CLI, see [What is the Amazon Command Line Interface?](https://docs.amazonaws.cn/cli/latest/userguide/cli-chap-welcome.html) in the *Amazon Command Line Interface User Guide*.

To install the Amazon CLI, see [ Installing or updating the latest version of the Amazon CLI](https://docs.amazonaws.cn/cli/latest/userguide/getting-started-install.html) in the *Amazon Command Line Interface User Guide*.

## Step 5: Use the Amazon CLI to configure Amazon credentials
<a name="prerequisites-configure-credentials"></a>

**To configure credentials with IAM Identity Center**
+ To configure credentials with IAM Identity Center, see [Configure your profile with the Amazon configure sso wizard](https://docs.amazonaws.cn/cli/latest/userguide/cli-configure-sso.html#cli-configure-sso-configure).

**To configure credentials with the Amazon CLI**

1. Run the `aws configure` command from the command line.

1. Configure the following. Select each link to learn more:

   1. [ Access key ID](https://docs.amazonaws.cn/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)

   1. [ Secret access key](https://docs.amazonaws.cn/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-creds)

   1. [Amazon Web Services Region](https://docs.amazonaws.cn/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-region)

   1. [ Output format](https://docs.amazonaws.cn/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-format)

   The following example shows sample values.

   ```
   $ aws configure
   AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
   AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
   Default region name [None]: us-west-2
   Default output format [None]: json
   ```

The Amazon CLI stores this information in a *profile* (a collection of settings) named `default` in the `credentials` and `config` files. These files are located in the `.aws` file in your home directory. By default, the information in this profile is used when you run an Amazon CLI command that doesn't explicitly specify a profile to use. For more information on the `credentials` file, see [ Configuration and credential file settings](https://docs.amazonaws.cn/cli/latest/userguide/cli-configure-files.html) in the *Amazon Command Line Interface User Guide*.

For more information on configuring credentials, such as using an existing configuration and credentials file, see [Quick setup](https://docs.amazonaws.cn/cli/latest/userguide/getting-started-quickstart.html) in the *Amazon Command Line Interface User Guide*.

## Step 6: (Optional) Install Amazon Toolkit for VS Code
<a name="prerequisites-install-vscode"></a>

For developers who prefer an integrated development environment, the Amazon Toolkit for VS Code provides powerful features for serverless development including visual debugging, CodeLens integration, and streamlined deployment workflows.

**Prerequisites for VS Code development**
+ Visual Studio Code (version 1.73.0 or a later version) installed on your system
+ YAML language support extension for VS Code

**To install the Amazon Toolkit for VS Code**

1. Open Visual Studio Code

1. Open the Extensions view (Ctrl\$1Shift\$1X or Cmd\$1Shift\$1X)

1. Search for "Amazon Toolkit"

1. Install the "Amazon Toolkit" extension by Amazon Web Services

1. Install the "YAML" extension by Red Hat (required for SAM template CodeLens features)

**Benefits of using VS Code with Amazon SAM**
+ Visual debugging: Set breakpoints and step through your Lambda functions locally
+ CodeLens integration: Build, deploy, and invoke functions directly from your SAM template
+ Integrated terminal: Access Amazon SAM Amazon CLI commands without leaving your editor
+ Template validation: Real-time validation and IntelliSense for SAM templates

For information about configuring your Amazon credentials in VS Code, see [ Setting up credentials](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/setup-credentials.html) in the Amazon Toolkit for VS Code User Guide.

## Next steps
<a name="prerequisites-next-steps"></a>
+ You are now ready to install the Amazon SAM CLI and start using Amazon SAM. To install the Amazon SAM CLI, see [Install the Amazon SAM CLI](install-sam-cli.md).
+ To set up Visual Studio Code for serverless development, see [Setting up the Amazon Toolkit for VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/setting-up.html).