AWS: VS Code Setup

A beginner's guide

VS Code can be linked with the AWS account. This allows developers to interact with AWS resources from the familiar VS Code interface. Let's cover the steps below:

Step 1: Install AWS CLI

The AWS Command Line Interface (AWS CLI) is an open-source tool that enables you to interact with AWS services using commands in your command-line shell.
To install, navigate to this URL aws.amazon.com/cli and install the relevant package.

Screenshot 2022-03-12 at 10.46.29.png

Step 2: Configure AWS Profile

Open a terminal in VS code, or you may open the terminal/powershell directly. Type in "aws configure".
You will be prompted for configuration values such as your AWS Access Key Id and your AWS Secret Access Key. The AWS CLI will create a config file in the default location of ~/.aws/config. Screenshot 2022-03-12 at 10.59.21.png

NOTE: If you do not have AWS access key & secret details, please follow the below steps:

  1. Open the IAM console at console.aws.amazon.com/iam.
  2. On the navigation menu, choose Users.
  3. Choose your IAM user name (not the check box).
  4. Open the Security credentials tab, and then choose Create access key.
  5. To see the new access key, choose Show. Your credentials resemble the following: - Access key ID: AKIAIOSFODNN7EXAMPLE
    - Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
  6. To download the key pair, choose Download .csv file. Store the .csv file with keys in a secure location.

Step 3: AWS Toolkit

Open VS Code and select "Extensions" from the left menu bar. Search for "AWS Toolkit" and install. Screenshot 2022-03-12 at 11.29.02.png The "AWS" menu item should now be visible in the left bar, and it should load the region configured in "Step 2" above. Based on the user rights configured in "Step 2", AWS resource lists should now appear along with options like "Create bucket", "Create Lambda sam application" etc. Screenshot 2022-03-12 at 11.44.24.png

Step 4: VS Code Workspace

If you attempt to download a Lambda and do not have any VS Code workspace open below error will appear: Screenshot 2022-03-12 at 12.29.30.png A Visual Studio Code "workspace" is the collection of one or more folders that are opened in a VS Code window (instance). AWS Toolkit uses this location as the target location to download data, hence the error.

Add Folder to Workspace

The File > Add Folder to Workspace command brings up an Open Folder dialog to select the new folder.

image.png

Once the workspace folder is connected, Lambda download should work. This will allow you to edit the code, install additional dependencies, etc., and upload it to AWS.