How To Connect VS Code To AWS
In this article, we’ll learn briefly about Amazon Web Services (AWS) and then go through a hands-on procedure to connect Visual Studio Code (VS Code) to AWS with the credential and configuration.
Amazon Web Services (AWS)
Amazon Web Services is one of the leading cloud computing platforms and provides services related to remote computing, servers, security, storage, networking, and many more. It provides scalable and reliable solutions for cloud computing for businesses across the globe and controls 31% of the market share in the cloud computing infrastructure globally.
Visual Studio (VS) Code
Visual Studio Code can be understood as a code editor with an integrated development environment that is optimized and refined in order to support the process of building and debugging applications for the modern web and cloud. It was made by Microsoft for operating systems ranging from Windows, macOS, and Linux and supports numerous features such as intelligent code completion, syntax highlighting, code refactoring, and many more.
Learn more about VS Code from the article, Getting Started with Visual Studio Code.
Connecting Visual Studio Code to Amazon Web Services
Step 1
First of all, Open Extensions Tab in VS Code. There are basically two ways to do it.
One is the Shortcut with CTRL + SHIFT + X and the other through the Menubar.
Files -> Preferences -> Extension.
Step 2
Search AWS in the search bar,
Step 3
Click on the Install under AWS Toolkit,
Step 4
In order to obtain the Access Key ID and Secret Access Key from AWS, login to the AWS account and visit the IAM console at this IAM link. From the Navigation Menu choose the Users. Choose the Security Credentials tab and Select Create Access Key. The Credentials would resemble something similar as following:
Access Key ID: HSAJXXXXXXODNN7EXAMPLE
Secret Access Key: PalrXUXXXXX/K7MDENG/bnWERfiPOEXAMPLEKEY
Step 5
Create a new file named ‘credentials’ and save it under the folder
For Windows OS: %USERPROFILE%\.aws\credentials
For macOS and Linux: ~/.aws/credentials
If the .aws directory is not present in the location under USERPROFILE which is your default USER Directory in Main Drive, create the folder first and save the files under that directory.
The ‘credentials’ file must contain the following detail,
[default]
aws_access_key_id=COPY_OF_the_ACCESSKEYID_FROM_AWS_IAM
aws_secret_access_key=COPY_OF_the_SECRETACCESSKEY_FROM_AWS_IAM
aws_session_token=COPY_OF_the_SESSION_TOKEN_IF_PROVIDED_FROM_REFERENCE
Step 6
Create a new file named ‘config’ with the details as follows,
[default]
region=us-west-2
output=json
Save the file config under the folder,
For Windows OS: %USERPROFILE%\.aws\config
For macOS and Linux: ~/.aws/config
If the .aws directory is not present in the location under USERPROFILE which is your default USER Directory in Main Drive, create the folder first and save the files under that directory.
STEP 7 — Connection to AWS
As the credentials and config are saved, Open the command palette in the Visual Studio Code with the following commands:
For Windows: CTRL + SHIFT + P
For macOS and Linux: Cmd + Shift + P
Now, Select AWS: Connect to AWS.
Once, the Successful Connection is done, AWS: profile with the title name will appear on the VS Code’s lower left bar.
Learn Similar Articles in C# Corner: