Lab 1: AWS Visual Studio Toolkits

Author: Kirk Davis, Dean Suzuki (4/22/20)

Install and Configure the AWS Toolkit for Visual Studio

Self-Paced Lab Duration: ~45 minutes

Purpose & Background

The purpose of this lab is to install and configure the AWS Toolkit for Microsoft Visual Studio (2017+, 2019 preferred), create an IAM user with console and programmatic access, and configure the AWS Toolkit to use the programmatic access credentials. You will use this IAM user to access the AWS console for the remainder of today’s labs.

Step1: Install the AWS Toolkit for Visual Studio

Follow the steps below to install the AWS Toolkit for Visual Studio

  1. Launch Visual Studio. Select Continue without code if Visual Studio prompts.

    • In Visual Studio 2017, go to Tools > Extensions and Updates.
    • In Visual Studio 2019, go to Extensions > Manage Extensions.
  2. Select the Online node in the left-panel and then in the search box enter: “AWS Toolkit” (without quotations). Then press ENTER to search.

  3. Click the Download button for the AWS Toolkit for Visual Studio 2017 and 2019.

  4. Once the AWS Toolkit for Visual Studio has downloaded, a message will appear at the bottom of the Extensions and Updates dialog window letting you know that your changes will be scheduled. Press Close to close the Extensions and Updates dialog window and Exit Visual Studio.

  5. Upon exiting Visual Studio, a VSIX Installer screen will appear to install the AWS Toolkit. To proceed with the installation, click Modify.

  6. Once the installation has successfully completed, close the VSIX Installer and re-launch Visual Studio. In Visual Studio, go to View. You should see AWS Explorer as an option and click that option.

Step 2: Create AWS Credentials for the AWS Toolkit

Follow the steps below to create a new AWS IAM user, which you will use for both the AWS Toolkit for Visual Studio, and to use the AWS Management Console for the remainder of the day.

  1. On the machine that you are running Visual Studio, login to the IAM Users page in the AWS Console. You can access this page by visiting https://console.aws.amazon.com/iam/home#/users. Please note that in the Immersion Day lab experience, we provide a virtual machine running Visual Studio. If you are using this environment, please ensure that you are opening the AWS Management console on this machine.

  2. Click the Add User button at the top of the page.

  3. On the initial Add User screen, select a username.

    Note: If you are working in a shared AWS account, please use your initials followed by a period and “awstoolkit”. For instance, jd.toolkitforvisualstudio for John Doe. If you are in an EventEngine account, choose whatever username you wish - note it down so that you don’t forget it later.

  4. Under Select AWS Access Type, select both checkboxes, for Programmatic Access and AWS Management Console access.

    IAM Add User screenshot

  5. For ‘Console password’ (which appears when you check the second checkbox above), select ‘Custom password’, and enter in a password. Make a note of your password, or commit it to memory.

  6. Uncheck the box for ‘Require password reset’. If you do not uncheck the box, you will need to create a new password on first login.

  7. Click Next: Permissions

  8. Under Set Permissions, select Attach Existing Policies Directly, and check the box next to AdministratorAccess, then click Next: Tags. IAM Set Permissions

  9. Click Next: Review. On the Review page, review the details on the Review screen to ensure that everything is correct before clicking the Create User button.

  10. On the Success screen, click Download .csv to download a CSV file containing your newly created Access Key ID and Secret Access Key. You will need these credentials later. Please note the location of the csv file. It should be in your Downloads folder.

    IAM New User success

Step 3: Configure Toolkit with Credentials

  1. Back in Visual Studio, create a new account profile.
    • Click the person icon with the green plus screen (see below).
      AWS Explorer Add Profile
    • On the New Account Profile, click the Import from csv File button under the Credential Setup section and select the credentials.csv file you just downloaded from IAM Management Console. AWS Explorer Add Profile
  2. You will see that the Access Key and Secret Key auto-fill. You do not need to specify an account number. Press Ok button.

Note: You can also manually copy/paste the Access Key ID and Secret Access Key into the New Profile dialog box. You don’t need to enter the AWS Account ID, that’s just for you to identify the account later.

Congratulations!

You have successfully configured the default profile for authenticating and accessing AWS through the AWS Toolkit for Visual Studio.

OPTIONAL Step 1: Install the AWS CLI and configure credentials

Note: Installing and configuring the AWS CLI is optional, and is not required to complete the labs when using Visual Studio and the AWS Toolkit.

If you want to interact with the AWS APIs via the Windows command prompt, install the AWS CLI for Windows. The easiest way to install this is to use the MSI installer, available here:

https://docs.aws.amazon.com/cli/latest/userguide/install-windows.html#install-msi-on-windows

After running the installer, you need to configure AWS credentials in order to use the CLI. Open a command prompt, and ensure the CLI is installed with the following command:

aws --version

If the CLI is installed, the version of the CLI, Python and botocore (the AWS library for Python) will be displayed.


Note: Before configuring your credentials below, if you are unsure at all whether to use the aws configure command or to manually create or edit the .aws\credentials file, please check with your AWS Solution Architect.


If you are using your own AWS account, or credentials for an AWS IAM User (that has programmatic access using an Access Key ID and Secret Access Key that you downloaded previously), you can configure the local credentials file with the following command:

aws configure

You will be prompted for your AWS Access Key ID, AWS Secret Access Key, Default region name, and Default output format. You can leave the default output blank. For default region, please use the region specified for the day (for instance, us-west-2).


If you using an AWS Event Engine account, where you are provided access keys as well as a session token, use the following steps instead to manually configure the local credentials file.

Note - if you already have an AWS credentials file, skip steps 1 - 5, and start with step 6

  1. In a command prompt window, change directory to your user profile directory with the following command:

    cd %USERPROFILE%
    
  2. Type dir for a list of files in your profile folder. If there is a folder named .aws already present, skip ahead to step 3.

  3. Create a new directory in your user profile folder, called, “.aws” with the following command. Note the period (“.”) at the start of the folder name:

    mkdir .aws
    
  4. Change directory into the newly created .aws folder:

    cd .aws
    
  5. If the .aws folder already existed, and you did not just create it, type dir again to see if the credentials file already exists. If it does already exist, skip to step 6.

  6. Create a blank text file called, “credentials” using the following command:

    copy NUL credentials
    
  7. Next, open the file in Notepad by typing the following command:

    notepad credentials
    

    (Note: you can use another text editor if you prefer)

  8. Copy the temporary credentials you were provided (from AWS Event Engine, or as provided by your Solutions Architect) and paste them into the credentials file.

  9. Add a profile name at the top of the file surrounded by square brackets. For today’s lab, use [labs] to create a profile called, “labs”. See the example below.

  10. Format the keys, token and region like this example below. Note that the aws_access_key_id, aws_secret_access_key, etc, are in lower case:

    [labs]
    
    aws_access_key_id=ASIAX6K6DW3D7Z7XKWXK
    
    aws_secret_access_key=Z1Q9rEirqxvn9Tah5XL41Evb9ynkoBgJb5SBoiJJ
    
    aws_session_token=FQoGZXIvYXdzEDEaDD6qwfjdOxYjwDQGOCLuAXBwDtz+aHvKp33/CD6gU...
    
    aws_default_region=us-west-2

    *Note: Do not copy the actual key values or token value from this lab guide. These are just examples to show you how to format your credentials in the credentials file. Also, note that there is no, “export” at the start of each line.*

  11. Save the file.

Now that your temporary credentials are configured, the labs profile will show up in the AWS Explorer pane in Visual Studio. Select this profile to ensure it is the default for deploying applications from Visual Studio to AWS.

OPTIONAL Section 2: Install the Toolkit for VS Code

Note: Installing and configuring the AWS Toolkit for VS Code is optional, and is not required to complete the labs when using Visual Studio and the AWS Toolkit.

  1. Start the VS Code editor.

  2. In the Activity Bar on the side of the VS Code editor, choose the Extensions icon. This opens the Extensions view, which allows you to access the VS Code Marketplace. The Extensions icon in the VS Code Activity Bar

  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 to enable you to access your AWS resources from within VS Code.

Restart VS Code

Configure AWS Profile

AWS credentials can be provided to the AWS Toolkit for VS Code by using your shared AWS credentials file. The methods for using these files are the same as those for the AWS CLI.

You should have already created a credentials file in the prior section, “Install AWS CLI”. Now, you just need to tell the AWS Toolkit for VS Code which profile to use.

  1. Open VS Code.
  2. Click the “AWS” logo/button in VS Code’s left-vertical menu to open the toolkit.
  3. Click the “Connect to AWS” link.
  4. In the drop-down, select the profile you created earlier for use with the AWS Event Engine account provided to you (or alteratively, select a profile associated with your own AWS account if you prefer).
  5. If the region you are working in isn’t shown in the AWS Explorer pane, click the hamburger menu (“…”) at the top-right of the pane, then select, “Show region in the explorer”, then select the region from the drop-down list.

The AWS Toolkit for VS Code is now installed and configured.