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.
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.
NOTE: If you do not have AWS access key & secret details, please follow the below steps:
- Open the IAM console at console.aws.amazon.com/iam.
- On the navigation menu, choose Users.
- Choose your IAM user name (not the check box).
- Open the Security credentials tab, and then choose Create access key.
- To see the new access key, choose Show. Your credentials resemble the following:
- Access key ID: AKIAIOSFODNN7EXAMPLE
- Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- 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. 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.
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: 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.
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.