AWS Toolkit for Visual Studio Code

AWS Toolkit for Visual Studio Code

AWS Toolkit

♦ This extension makes it easier for developers to develop, debug locally, and deploy serverless applications that use Amazon Web Services (AWS).

You can use the AWS Toolkit for Visual Studio Code as follows:

  • Develop serverless applications locally, and then deploy them to an AWS account (see Usage).
  • Manage certain supported AWS resources in an AWS account (see Usage).
  • This includes:
    1. Listing and deleting AWS CloudFormation stacks.
    2. Listing and invoking AWS Lambda functions.

Required

  1. An Amazon Web Services account.
  2. A supported operating system – Windows, Linux, and macOS.
  3. VS Code version 1.31.1 or later.

(Optional)

  1. AWS SAM CLI – 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 below) because it is required for any AWS Serverless Application Model (AWS SAM) functionality such as Creating a Serverless Application. See how to install AWS SAM CLI in this link
  2. Docker – required by the AWS SAM CLI.

Install

    1. Open VScode and change to Extension tab in Activity bar. Search with keyword “AWS Toolkit for Visual Studio Code”.
      Note
      You  can also install this toolkit from Vscode Website with this link
    2. Choose Install.
    3. After if you’re prompted to restart the editor, choose Reload Required. Success installation, in Activity bar had AWS icon.

Get Your AWS Access Keys

♦ Access keys are the credentials that identify you to AWS and enable you to programmatically access AWS services and resources. Access keys can be associated with your AWS account (the account’s “root user”) or with users that you create with AWS Identity and Access Management (IAM).

Warning

Because the root user is essentially an administrator with full access to services and resources, we recommend that you instead create an IAM user with only those permissions needed to perform the required tasks. Then, for your credentials, you can use an access key that is associated with that user. For details, see this.

Create a new credential profile

  1. Open VSCode.
  2. Hold Ctrl + Shift + P (open Command Palette).
  3. Search and choose AWS: Create Credentials Profile.
  4. Enter profile name (ex: default).
  5. Enter access key id.
  6. Enter secret key.

Connect to AWS through the AWS Toolkit for Visual Studio Code

  1. Open VScode.
  2. Hold Ctrl + Shift + P (mở Command Palette).
  3. Search AWS: Connect to AWS.

  4. Choose a profile from the list.

    If have a small alert popup in the right bottom corner, choose Yes.
  5. Now, it had connected to AWS. You can choose your work region.

Run SAM Application in localhost

Requirement:
♦ An IAM user with Administration permission.
♦ Installed and started Docker.
♦ Installed AWS CLI and AWS SAM.
♦ In AWS S3 created 1 bucket.

  1. Choose Create new SAM Application.
  2. Choose language for a SAM application.
  3. Choose folder to save a new project.
  4. Input name for new project.
  5. This is a sample SAM project.
  6. In the localhost, open file app.js and then choose Run Locally to run SAM application.
  7. Then, return API result in tab Output of VScode.

Debug SAM Application in the localhost

Choose Debug Locally and add debug point where you want to show information.

Deploy SAM Application to AWS.

  1. Choose Deploy SAM Application.
  2. Choose a SAM template deploy to AWS.
  3. Choose AWS Region.
  4. Enter bucket name in S3 (This bucket is requirement exist in S3).
  5. Enter name for stack.
  6. When success uploaded to AWS, in AWS Explorer will show new CloudFormation and Lambda function.