AWS Toolkit For VS Code: User Guide
AWS Toolkit For VS Code: User Guide
AWS Toolkit For VS Code: User Guide
User Guide
AWS Toolkit for VS Code User Guide
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not
Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or
discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may
or may not be affiliated with, connected to, or sponsored by Amazon.
AWS Toolkit for VS Code User Guide
Table of Contents
AWS Toolkit for Visual Studio Code ...................................................................................................... 1
What is the AWS Toolkit for Visual Studio Code ............................................................................. 1
Related Information ................................................................................................................... 1
Setting Up ........................................................................................................................................ 2
Installing the Toolkit for VS Code ................................................................................................ 2
Prerequisites ...................................................................................................................... 2
Install the Toolkit for VS Code ............................................................................................. 3
Establishing Credentials .............................................................................................................. 3
Using AWS-Supported Credentials ........................................................................................ 4
Using an External Credential Process .................................................................................... 7
Connecting to AWS .................................................................................................................... 8
Connect to AWS through the Toolkit for VS Code ................................................................... 8
Use Multiple AWS Accounts with the Toolkit ........................................................................ 10
Changing AWS Regions ............................................................................................................. 10
Add a Region to the AWS Explorer ..................................................................................... 10
Hide a Region from the AWS Explorer ................................................................................. 12
Configuring Your Toolchain ....................................................................................................... 13
Configure a Toolchain for .NET Core ................................................................................... 13
Configure a Toolchain for Node.js ....................................................................................... 13
Configure a Toolchain for Python ....................................................................................... 13
Using Your Toolchain ........................................................................................................ 14
Navigating the Toolkit for VS Code .................................................................................................... 15
Fundamental UI Components ..................................................................................................... 15
Command Locations ................................................................................................................. 15
Visual Studio Code Command Palette ................................................................................. 16
AWS Explorer Menu ......................................................................................................... 17
Working with AWS Services ............................................................................................................... 18
AWS Serverless Applications ...................................................................................................... 19
Creating a Serverless Application ....................................................................................... 19
Deploying a Serverless Application ..................................................................................... 23
AWS Lambda Functions ............................................................................................................. 25
Interacting with Remote Lambda Functions ......................................................................... 25
AWS CloudFormation Stacks ...................................................................................................... 28
Deleting an AWS CloudFormation Stack .............................................................................. 28
Amazon ECS ............................................................................................................................ 29
Using IntelliSense for Task Definition Files ........................................................................... 29
Document History ............................................................................................................................ 31
iii
AWS Toolkit for VS Code User Guide
What is the AWS Toolkit for Visual Studio Code
Topics
Related Information
Use the following resources to access the source code for the toolkit or view currently open issues.
• Source Code
• Issue Tracker
To learn more about the Visual Studio Code editor, visit https://code.visualstudio.com/.
1
AWS Toolkit for VS Code User Guide
Installing the Toolkit for VS Code
Topics
• Installing the AWS Toolkit for Visual Studio Code (p. 2)
• Establishing Credentials for the AWS Toolkit for Visual Studio Code (p. 3)
• Connecting to AWS through the AWS Toolkit for Visual Studio Code (p. 8)
• Changing AWS Regions (p. 10)
• Configuring Your Toolchain (p. 13)
Prerequisites
Required
Before you can install the Toolkit for VS Code, you must have the following:
• An Amazon Web Services account – To obtain an AWS account, go to the AWS home page. Choose
Create an AWS Account, or Complete Sign Up (if you've visited the site before). Signing up enables
you to use all of the services that AWS offers.
• A supported operating system – The Toolkit for VS Code is supported on Windows, Linux, and macOS.
• The relevant SDK for the language that you want to use. You can download from the following links,
or use your favorite package manager:
• .NET SDK: https://dotnet.microsoft.com/download
• Node.js SDK: https://nodejs.org/en/download
• Python SDK: https://www.python.org/downloads
• VS Code version 1.31.1 or later – We try to keep the Toolkit for VS Code current with the default
version that's available on the VS Code download page.
Optional
Before you can use certain features of the Toolkit for VS Code, you must have the following:
• AWS SAM CLI – This is an AWS CLI tool that helps you develop, test, and analyze your serverless
applications locally. This isn't required for installing the toolkit. However, we recommend that you
install it (and Docker, described next) because it's required for any AWS Serverless Application Model
(AWS SAM) functionality, such as Creating a Serverless Application (p. 19).
For more information, see Installing the AWS SAM CLI in the AWS Serverless Application Model
Developer Guide.
2
AWS Toolkit for VS Code User Guide
Install the Toolkit for VS Code
• Docker – The AWS SAM CLI requires this open-source software container platform. For more
information and download instructions, see Docker.
3. In the search box for Extensions, search for AWS Toolkit for Visual Studio Code. Choose the entry
to see its details in the right pane.
4. In the right pane, choose Install.
5. Once installed, if you're prompted to restart the editor, choose Reload Required to finish
installation.
After you install the Toolkit for VS Code, you should configure your credentials (p. 3) to enable you
to access your AWS resources from within VS Code.
You can obtain credentials through AWS and provide them to the toolkit by using configuration files. You
can also obtain credentials through an external credential process that isn't directly supported by AWS.
3
AWS Toolkit for VS Code User Guide
Using AWS-Supported Credentials
Topics
• Using AWS-Supported Credentials (p. 4)
• Using an External Credential Process (p. 7)
Topics
• Obtaining AWS Access Keys (p. 4)
• Setting Up Your AWS Credentials (p. 5)
For more information about users and credentials that is out of scope for this guide, see the following
resources:
An access key consists of an access key ID, which is similar to a user name, and a secret access key, which
is similar to a password. This access key is used to sign programmatic requests that you make to AWS. If
you don't have access keys, you can create them by using the AWS Management Console. We recommend
that you use access keys for an IAM user instead of the keys for your account's root user.
Note
To create access keys, you must have permissions to perform the required IAM actions. For more
information, see Granting IAM User Permissions to Manage Password Policy and Credentials in
the IAM User Guide.
4
AWS Toolkit for VS Code User Guide
Using AWS-Supported Credentials
3. Choose your IAM user name (not the check box) to view its details.
4. On the Security Credentials tab, choose Create access key.
5. To see the new access key, choose Show. The credentials resemble the following:
• Keep the keys confidential to protect your AWS account, and never email them. Do not
share them outside of 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.
• You can't recover the secret key if you lose it. Instead, for security reasons, you must
create a new key pair and delete the old pair.
After you have obtained your AWS access keys, you can use the AWS Toolkit for VS Code to store them in
your shared AWS config file or your shared AWS credentials file. See Add Your AWS Access Keys to Your
Environment (p. 5) to learn how.
The Toolkit for VS Code locates and uses AWS access keys through your shared AWS config file and your
shared AWS credentials file. This is the method that is used by the AWS CLI and the AWS SDKs. Access
keys that you enter in the Toolkit for VS Code are saved to one of these files.
These shared files can contain the credentials for more than one AWS account, stored as profiles. Multiple
accounts can be useful, for example, to provide developers and administrators with separate resources
for development and for release or publication.
5
AWS Toolkit for VS Code User Guide
Using AWS-Supported Credentials
set your AWS credentials, or if you want to include additional AWS credentials in your environment or
update an existing credentials profile, you can do so through the Toolkit for VS Code, as shown here.
Note
As an alternative to these procedures, you can use the aws configure AWS CLI command to add
AWS credentials to your environment. You can also use aws configure to set the default AWS
Region, which is needed for certain operations such as creating a serverless application.
• If you already have a shared AWS credentials file, you can skip to the next procedure (p. 7).
• If you already have a shared AWS config file and want to use it, you can skip to the next
procedure (p. 7).
• If you have only a shared AWS config file but do NOT want to use it, you must first create a shared AWS
credentials file by using techniques that are normal for your operating-system. After that, you can skip
to the next procedure (p. 7).
1. Open VS Code.
2. To open the Command Palette, on the menu bar, choose View, Command Palette. Or use the
following shortcut keys:
5. Enter the access key ID for the credentials. If you don't have an access key ID, see Obtaining AWS
Access Keys (p. 4).
6. Enter the secret access key for the credentials. If you don't have a secret access key, see Obtaining
AWS Access Keys (p. 4).
6
AWS Toolkit for VS Code User Guide
Using an External Credential Process
After you complete this procedure, you can verify the shared AWS credentials file by opening it directly
or by performing the first three steps of the next procedure (without making any updates).
Follow these steps to add a new profile to your existing shared AWS config file or shared AWS credentials
file. You can also update an existing profile.
1. Open VS Code.
2. To open the Command Palette, on the menu bar, choose View, Command Palette. Or use the
following shortcut keys:
4. When one or both of the shared files opens in the VS Code editor, add or update a profile.
5. When you're finished updating the file, save it.
The method for specifying such an external credential process is the same as for the AWS CLI, and
consists of adding a credential_process definition to your shared AWS config file. For detailed
information about how to do this, see Sourcing Credentials with an External Process in the AWS
Command Line Interface User Guide.
7
AWS Toolkit for VS Code User Guide
Connecting to AWS
If you don't have a credentials profile set up, you are prompted to set one up. Look for a pop-up
in the lower-right corner of the editor. Choose Yes, and then follow the setup wizard to enter a
profile name, your access key ID, and your secret access key. For details, see Setting Up Your AWS
Credentials (p. 5).
Note
If you want to provide an external credential process instead of using AWS-supported
credentials, choose No and see Using an External Credential Process (p. 7) instead.
8
AWS Toolkit for VS Code User Guide
Connect to AWS through the Toolkit for VS Code
5. Open the AWS: Explorer Side Bar, which we call the AWS Explorer, to verify the connection. You
will see either a list of AWS Regions (if you have made any Regions visible (p. 10) in the AWS
Explorer) or a message to add Regions to the AWS Explorer.
Before adding Regions (p. 10) to the AWS Explorer, you see the following.
After adding Regions to the AWS Explorer, you see something like the following.
9
AWS Toolkit for VS Code User Guide
Use Multiple AWS Accounts with the Toolkit
Separate sets of AWS credentials are stored as profiles within the shared AWS config file or the shared
AWS credentials file. To choose a different set of credentials, follow the steps in the previous procedure,
and choose a different profile.
10
AWS Toolkit for VS Code User Guide
Add a Region to the AWS Explorer
3. Choose the Region that you want to add to the AWS Explorer.
Note
The list contains only those Regions that are available to add to the AWS Explorer. Regions
you've already added don't appear in the list.
4. Verify that the Region now appears in the AWS Explorer.
11
AWS Toolkit for VS Code User Guide
Hide a Region from the AWS Explorer
12
AWS Toolkit for VS Code User Guide
Configuring Your Toolchain
13
AWS Toolkit for VS Code User Guide
Using Your Toolchain
14
AWS Toolkit for VS Code User Guide
Fundamental UI Components
For general information about the Visual Studio Code user interface (UI), see the UI documentation for
VS Code.
Fundamental UI Components
The following are the basic UI components of the AWS Toolkit for VS Code.
The UI element named AWS Explorer is more formally known as the AWS: Explorer Side Bar.
Command Locations
You can find the commands for the Toolkit for VS Code in various locations.
15
AWS Toolkit for VS Code User Guide
Visual Studio Code Command Palette
16
AWS Toolkit for VS Code User Guide
AWS Explorer Menu
17
AWS Toolkit for VS Code User Guide
• If the toolkit is installed and configured correctly, you should see items in the AWS Explorer. To see
the AWS Explorer, choose the AWS icon in the Activity bar.
For example:
• Certain features require certain AWS permissions. For example, to see the AWS Lambda functions
in your AWS account, the credentials you configured in Establishing Credentials (p. 3) must include
at least read-only Lambda permissions. See the following topics for more information about the
permissions that each feature needs.
Topics
• Working with AWS Serverless Applications (p. 19)
18
AWS Toolkit for VS Code User Guide
AWS Serverless Applications
Topics
• Creating a Serverless Application with the AWS Toolkit for Visual Studio Code (p. 19)
• Deploying a Serverless Application with the AWS Toolkit for Visual Studio Code (p. 23)
Prerequisites
• If you haven't already done so, satisfy the required prerequisites specified in Installing the Toolkit for
VS Code (p. 2).
• In addition, install the AWS SAM CLI and its prerequisites. See AWS SAM CLI in the setup
prerequisites (p. 2). If Visual Studio Code is open when you perform these installations, you might need
to close and reopen the editor.
• Identify your default AWS Region in your AWS config file. For more information, see Configuration and
Credential Files in the AWS CLI User Guide. If Visual Studio Code is open when you update your config
file, you might need to close and reopen the editor.
• After installing your language SDK, be sure to configure your toolchain (p. 13).
1. To open the Command Palette, choose View, Command Palette, and then enter AWS.
2. Choose AWS: Create new SAM Application.
Note
If the AWS SAM CLI isn't installed, you will get an error in the lower-right corner of the VS
Code editor. If this happens, see the prerequisites (p. 19) described earlier.
3. Choose the runtime for your SAM application. For this example, choose nodejs10.x.
19
AWS Toolkit for VS Code User Guide
Creating a Serverless Application
4. Choose a location for your new project. You can use an existing workspace folder if one is open,
Select a different folder that already exists, or create a new folder and select it. For this example,
choose There are no workspace folders open to create a folder named MY-SAM-APP.
5. Enter a name for your new project. For this example, use my-sam-app-nodejs. After you press
Enter, the Toolkit for VS Code takes a few moments to create the project.
When the project is created, your application is added to your current workspace. You should see it listed
in the Explorer window.
20
AWS Toolkit for VS Code User Guide
Creating a Serverless Application
1. From the hello-world directory in the project explorer, open app.js, if it isn't already open.
21
AWS Toolkit for VS Code User Guide
Creating a Serverless Application
If CodeLens indicators aren't visible, select the AWS Explorer icon in the Activity Bar to activate
CodeLens.
22
AWS Toolkit for VS Code User Guide
Deploying a Serverless Application
3. After the local run is complete, the output appears on the OUTPUT tab or the TERMINAL tab.
Note
For Windows users, if you encounter a Docker mounting error during this process, you
might need to refresh the credentials for your shared drives (in Docker Settings). A Docker
mounting error might look something like the following.
4. Choose the Debug Locally CodeLens indicator to debug your application. When in debug mode, you
can set breakpoints, step through each line, inspect variables, and change values just as you would
for any application.
Prerequisites
• If you haven't already done so, satisfy the prerequisites specified in Installing the Toolkit for VS
Code (p. 2).
• Be sure to choose a globally unique Amazon S3 bucket name.
• Ensure that the credentials you configured in Establishing Credentials (p. 3) include the appropriate
read/write access to the following services: Amazon S3, AWS CloudFormation, AWS Lambda, and
Amazon API Gateway.
23
AWS Toolkit for VS Code User Guide
Deploying a Serverless Application
5. Enter the name of an Amazon S3 bucket this deployment can use. The bucket must be in the Region
you're deploying to.
Warning
The Amazon S3 bucket name must be globally unique across all existing bucket names
in Amazon S3. Therefore, you should add a unique identifier to the name given in the
following example (or choose a different name).
6. Enter a name for the deployed stack, either a new stack name or an existing stack name.
24
AWS Toolkit for VS Code User Guide
AWS Lambda Functions
If an error occurs, a message pops up in the lower-right that is similar to the following:
If this happens, check the text in the OUTPUT tab for details. The following is an example of error
details.
In this example, the error occurred because the Amazon S3 bucket did not exist.
When the deployment is complete, you'll see your application listed in the AWS Explorer. To learn how
to invoke the Lambda function that was created as part of the application, see Interacting with Remote
Lambda Functions (p. 25).
Lambda is a fully managed compute service that runs your code in response to events generated by
custom code or from various AWS services, such as Amazon Simple Storage Service (Amazon S3),
Amazon DynamoDB, Amazon Kinesis, Amazon Simple Notification Service (Amazon SNS), and Amazon
Cognito.
Topics
• Interacting with Remote Lambda Functions (p. 25)
For more information about Lambda, see the AWS Lambda Developer Guide.
25
AWS Toolkit for VS Code User Guide
Interacting with Remote Lambda Functions
Note
If you have already created Lambda functions by using the AWS Management Console or in
some other way, you can invoke them from the Toolkit. To create a new function (using VS Code)
that you can deploy to AWS Lambda, you must first create a serverless application (p. 19).
Prerequisites
• If you haven't already done so, satisfy the prerequisites specified in Installing the Toolkit for VS
Code (p. 2).
• Ensure that the credentials you configured in Establishing Credentials (p. 3) include appropriate read/
write access to the AWS Lambda service. If in the AWS Explorer, under Lambda, you see a message
similar to "Error loading Lambda resources", check the permissions attached to those credentials.
Changes that you make to permissions will take a few minutes to affect the AWS Explorer in VS Code.
1. In the AWS Explorer, choose the name of the Lambda function you want to invoke, and then open
its context menu.
26
AWS Toolkit for VS Code User Guide
Interacting with Remote Lambda Functions
You'll see the output of the Lambda function just like you would for any other project using VS Code.
27
AWS Toolkit for VS Code User Guide
AWS CloudFormation Stacks
1. In the AWS Explorer, choose the name of the Lambda function you want to delete, and then open
its context menu.
2. Choose Delete.
3. In the message that appears, choose Yes to confirm the delete.
After the function is deleted, it's no longer listed in the AWS Explorer.
Topics
• Deleting an AWS CloudFormation Stack (p. 28)
28
AWS Toolkit for VS Code User Guide
Amazon ECS
Prerequisites
• If you haven't already done so, satisfy the prerequisites specified in Installing the Toolkit for VS
Code (p. 2).
• Ensure that the credentials you configured in Establishing Credentials (p. 3) include appropriate read/
write access to the AWS CloudFormation service. If in the AWS Explorer, under CloudFormation, you
see a message similar to "Error loading CloudFormation resources", check the permissions attached to
those credentials. Changes that you make to permissions will take a few minutes to affect the AWS
Explorer in VS Code.
1. In the AWS Explorer, open the context menu of the AWS CloudFormation stack you want to delete.
After the stack is deleted, it's no longer listed in the AWS Explorer.
Topics
• Using IntelliSense for Amazon ECS Task Definition Files (p. 29)
29
AWS Toolkit for VS Code User Guide
Using IntelliSense for Task Definition Files
Prerequisites
• If you haven't already done so, satisfy the prerequisites specified in Installing the Toolkit for VS
Code (p. 2).
1. Create a JSON file for your Amazon ECS task definition. The file's name must have ecs-task-
def.json at the end, but can have additional characters at the beginning.
30
AWS Toolkit for VS Code User Guide
The following table describes important changes in each release of the AWS Toolkit for Visual Studio
Code. For notification about updates to this documentation, you can subscribe to an RSS feed.
Using an External Credential Added information about using September 25, 2019
Process (p. 7) an external credential process to
obtain AWS credentials.
Using IntelliSense for Task IntelliSense support was added September 24, 2019
Definition Files (p. 29) for working with Amazon ECS
task Definition files.
User Guide for the AWS Toolkit Release for general availability. July 11, 2019
for Visual Studio Code (p. 1)
User Guide for the AWS Toolkit Updated the document structure July 3, 2019
for Visual Studio Code (p. 1) for clarity and ease of use.
Installing the AWS Toolkit for VS Added information about June 12, 2019
Code (p. 2) installing language SDKs to
support various toolchains.
Configure Your Toolchain (p. 13) Added information about June 12, 2019
configuring various toolchains.
Initial Release (p. 31) Initial release of the user guide March 28, 2019
for AWS Toolkit for Visual Studio
Code.
31