AWS Toolkit For Visual Studio - User Guide

Transcription

AWS Toolkit for Visual StudioUser GuideAWS Toolkit for Visual Studio: User GuideCopyright Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

AWS Toolkit for Visual Studio User GuideAmazon's trademarks and trade dress may not be used in connection with any product or service that is notAmazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages ordiscredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who mayor may not be affiliated with, connected to, or sponsored by Amazon.

AWS Toolkit for Visual Studio User GuideTable of ContentsAWS Toolkit for Visual Studio . 1What is the Toolkit for Visual Studio . 1AWS Explorer . 1Credential and Region Management . 1Amazon EC2 . 1AWS Lambda . 1AWS CodeCommit . 2Amazon DynamoDB . 2Amazon S3 . 2Amazon RDS . 2AWS Elastic Beanstalk . 2AWS CloudFormation . 2AWS Identity and Access Management (IAM) . 2Related Information . 2Setting Up the AWS Toolkit for Visual Studio . 4Setting up the AWS Toolkit for Visual Studio . 4Prerequisites . 4Install the Toolkit for Visual Studio . 4Uninstall the Toolkit for Visual Studio . 5Older versions of the Toolkit for Visual Studio . 6Providing AWS credentials . 6Credentials locations . 7Options for configuring credentials . 7Creating profiles for AWS credentials . 7Using AWS SSO . 11Using MFA . 12Using external credentials . 15Using the Toolkit for Visual Studio . 15Profiles and Toolkit for Visual Studio Window Binding . 15Working with AWS Services . 17Managing Amazon EC2 Instances . 17The Amazon Machine Images and Amazon EC2 Instances Views . 17Launching an Amazon EC2 Instance . 19Connecting to an Amazon EC2 Instance . 22Ending an Amazon EC2 Instance . 25Managing Amazon ECS Instances . 27Modifying service properties . 27Stopping a task . 27Deleting a service . 27Deleting a cluster . 28Creating a repository . 28Deleting a repository . 28Managing Security Groups from AWS Explorer . 28Creating a Security Group . 29Adding Permissions to Security Groups . 29Create an AMI from an Amazon EC2 Instance . 31Setting Launch Permissions on an Amazon Machine Image . 32Amazon Virtual Private Cloud (VPC) . 33Creating a Public-Private VPC for Deployment with AWS Elastic Beanstalk . 34Deployment Using the AWS Toolkit . 37Publish to AWS (preview feature) . 38Deploying to Elastic Beanstalk . 42Deploying to Amazon EC2 Container Service . 81Using the AWS CloudFormation Template Editor for Visual Studio . 92iii

AWS Toolkit for Visual Studio User GuideCreating an AWS CloudFormation Template Project in Visual Studio . 92Deploying a AWS CloudFormation Template in Visual Studio . 94Estimating the Cost of Your AWS CloudFormation Template Project in Visual Studio . 96Formatting a AWS CloudFormation Template in Visual Studio . 98Using Amazon S3 from AWS Explorer . 99Creating an Amazon S3 Bucket . 99Managing Amazon S3 Buckets from AWS Explorer . 100Uploading Files and Folders to Amazon S3 . 101Amazon S3 File Operations from AWS Toolkit for Visual Studio . 102Using DynamoDB from AWS Explorer . 106Creating an DynamoDB Table . 107Viewing an DynamoDB Table as a Grid . 108Editing and Adding Attributes and Values . 109Scanning an DynamoDB Table . 110Using AWS CodeCommit with Visual Studio Team Explorer . 112Credential Types for AWS CodeCommit . 112Connecting to AWS CodeCommit . 112Creating a Repository . 113Setting up Git Credentials . 114Cloning a Repository . 117Working with Repositories . 117Using CodeArtifact in Visual Studio . 118Add your CodeArtifact repository as a NuGet package source . 118Amazon RDS from AWS Explorer . 119Launch an Amazon RDS Database Instance . 119Create a Microsoft SQL Server Database in an RDS Instance . 125Amazon RDS Security Groups . 127Using Amazon SimpleDB from AWS Explorer . 130Using Amazon SQS from AWS Explorer . 131Creating a Queue . 132Deleting a Queue . 132Managing Queue Properties . 132Sending a Message to a Queue . 133Identity and Access Management . 134Create and Configure an IAM User . 134Create an IAM Group . 135Add an IAM User to an IAM Group . 136Generate Credentials for an IAM User . 137Create an IAM Role . 139Create an IAM Policy . 140Using the AWS Lambda Templates in the AWS Toolkit for Visual Studio . 142Basic AWS Lambda Project . 142Basic AWS Lambda Project Creating Docker Image . 149Tutorial: Build and Test a Serverless Application with AWS Lambda . 154Tutorial: Creating an Amazon Rekognition Lambda Application . 164Tutorial: Using Amazon Logging Frameworks with AWS Lambda to Create Application Logs . 172Deploying an AWS Lambda Project with the .NET Core CLI . 173Prerequisites . 174Related topics . 174Listing the Lambda Commands Available through the .NET Core CLI . 174Publishing a .NET Core Lambda Project from the .NET Core CLI . 175Security . 177Data Protection . 177Identity and Access Management . 178Compliance Validation . 178Resilience . 179Infrastructure Security . 179iv

AWS Toolkit for Visual Studio User GuideConfiguration and Vulnerability Analysis .Document history .Document history .Earlier updates .v179181181182

AWS Toolkit for Visual Studio User GuideWhat is the Toolkit for Visual StudioAWS Toolkit for Visual StudioThis is the user guide for the AWS Toolkit for Visual Studio. If you are looking for the AWS Toolkit forVS Code, see the User Guide for the AWS Toolkit for Visual Studio Code.What is the Toolkit for Visual StudioThe AWS Toolkit for Visual Studio is a plugin for the Visual Studio IDE that makes it easier for you todevelop, debug, and deploy .NET applications that use Amazon Web Services. The Toolkit for VisualStudio is supported for Visual Studio versions 2017 and later. For details about how to download andinstall the kit, see Install the Toolkit for Visual Studio (p. 4).NoteThe Toolkit for Visual Studio was also released for Visual Studio 2008, 2010, 2012, 2013, and2015 versions. However, those versions are no longer supported. For more information, seeInstall the Toolkit for Visual Studio (p. 4).The Toolkit for Visual Studio contains the following features to enhance your development experience.AWS ExplorerThe AWS Explorer tool window, available from the IDE's View menu, enables you to interact withmany of the AWS services from inside the Visual Studio IDE. Supported data services include AmazonSimple Storage Service (Amazon S3), Amazon SimpleDB, Amazon Simple Notification Service (AmazonSNS), Amazon Simple Queue Service (Amazon SQS), and Amazon CloudFront. AWS Explorer alsoprovides access to Amazon Elastic Compute Cloud (Amazon EC2) management, AWS Identity and AccessManagement (IAM) user and policy management, deployment of serverless applications and functions toAWS Lambda and deployment of web applications to AWS Elastic Beanstalk and AWS CloudFormation.Credential and Region ManagementAWS Explorer supports multiple AWS accounts (including IAM user accounts) and regions, and enablesyou to easily change the displayed view from one account to another or view and manage resources andservices in different regions.Amazon EC2From AWS Explorer, you can view available Amazon Machine Images (AMIs), create Amazon EC2 instancesfrom those AMIs, and then connect to those instances by using Windows Remote Desktop. AWS Exploreralso enables supporting functionality, such as the capability to create and manage key pairs and securitygroups.AWS LambdaYou can use Lambda to host your serverless .NET Core C# functions and serverless applications. Useblueprints to quickly create new serverless projects and get a head start in developing your serverlessapplication.1

AWS Toolkit for Visual Studio User GuideAWS CodeCommitAWS CodeCommitCodeCommit is integrated with Visual Studio Team Explorer. This makes it easy to clone and createrepositories held in CodeCommit, and to work with source code changes from within the IDE.Amazon DynamoDBDynamoDB is a fast, highly scalable, highly available, cost-effective, nonrelational database service. TheToolkit for Visual Studio provides functionality for working with Amazon DynamoDB in a developmentcontext. With the Toolkit for Visual Studio, you can create and edit attributes in DynamoDB tables andrun scan operations on tables.Amazon S3You can quickly and easily upload content to Amazon S3 buckets by dragging and dropping, or downloadcontent from Amazon S3. You can also set permissions, metadata, and tags conveniently on objects inbuckets.Amazon RDSAWS Explorer can help you create and manage Amazon RDS assets in Visual Studio. Amazon RDSinstances that use Microsoft SQL Server can also be added to Visual Studio's Server Explorer.AWS Elastic BeanstalkYou can use Elastic Beanstalk to deploy your .NET web application projects to AWS. You can deployyour application to a single instance environment or to a fully load balanced, automatically scaledenvironment from within the IDE. You can also deploy new versions of your application quickly andconveniently without leaving Visual Studio. If your application uses SQL Server in Amazon RDS, thedeployment wizard can also set up the connectivity between your application environment in ElasticBeanstalk and the database instance in Amazon RDS. The Toolkit for Visual Studio also includes thestandalone command-line deployment tool. Use the deployment tool to make deployment an automaticpart of your build process, or to include deployment in other scripting scenarios outside of Visual Studio.AWS CloudFormationYou can use the Toolkit for Visual Studio to edit AWS CloudFormation JSON-format templates withsupport for editor IntelliSense and syntax highlighting. With a AWS CloudFormation template youdescribe the resources you want to instantiate to host your application. From within the IDE you thendeploy the template to AWS CloudFormation. The resources described in the template are provisionedfor you, freeing you to focus on developing the application's functionality.AWS Identity and Access Management (IAM)From AWS Explorer, you can create IAM users, roles, and policies, and attach policies to users.Related InformationTo open an issues or view currently open issues, visit ssues.2

AWS Toolkit for Visual Studio User GuideRelated InformationTo learn more about Visual Studio, visit https://visualstudio.microsoft.com/vs/.3

AWS Toolkit for Visual Studio User GuideSetting up the AWS Toolkit for Visual StudioSetting Up the AWS Toolkit forVisual StudioThe topics in this section will help you set up and use the Toolkit for Visual Studio.Topics Setting up the AWS Toolkit for Visual Studio (p. 4) Providing AWS credentials (p. 6) Using the Toolkit for Visual Studio (p. 15)Setting up the AWS Toolkit for Visual StudioThis topic describes how to install and configure the Toolkit for Visual Studio.PrerequisitesTo install and configure the Toolkit for Visual Studio, you must: Have an AWS account. This account enables you to use AWS services. To get an AWS account, on theAWS home page, choose Create an AWS Account. Run a supported operating system: Windows 10, Windows 8, or Windows 7.We recommend that you install the latest service packs and updates for the Windows version you'reusing. Visual Studio 2017 or later (including Community editions).We recommend that you install the latest service packs and updates.NoteThe Toolkit for Visual Studio is still available if you're using Visual Studio versions 2008, 2010,2012, 2013, and 2015 (including Express editions where available). However, these versionsaren't supported. For Express editions, the installation includes only the AWS project templates.Visual Studio Express editions don't support third-party extensions, such as AWS Explorer. Findlinks to these older versions of the Toolkit for Visual Studio below in Older Versions of theToolkit for Visual Studio (p. 6).Install the Toolkit for Visual StudioInstall for Visual Studio 2022The Toolkit for Visual Studio for Visual Studio 2022 is distributed in the Visual Studio Marketplace.You can also install and update the toolkit within Visual Studio by using the main menu to navigate. (Visual Studio 2022) Extensions Manage Extensions4

AWS Toolkit for Visual Studio User GuideUninstall the Toolkit for Visual StudioIn the upper-right search box, search for AWS and choose Download for the "AWS Toolkit for VisualStudio 2022". Choose Close.After the toolkit has been installed, open it by choosing AWS Explorer from the View heading in themain menu.Install for Visual Studio 2017 and Visual Studio 2019The Toolkit for Visual Studio for Visual Studio 2017 and Visual Studio 2019 is distributed in theVisual Studio Marketplace. You can also install and update the toolkit within Visual Studio by usingthe main menu to navigate. (Visual Studio 2019) Extensions Manage Extensions (Visual Studio 2017) Tools Extensions and UpdatesIn the upper-right search box, search for AWS and choose Download for the "AWS Toolkit for VisualStudio 2017 and 2019". Choose Close.After the toolkit has been installed, open it by choosing AWS Explorer from the View menu.Install for Visual Studio 2013 and Visual Studio 2015The Toolkit for Visual Studio for Visual Studio 2013 and Visual Studio 2015 are part of the AWSTools for Windows. You can install the AWS Tools for Windows for these versions as follows.1. Navigate to the page AWS Toolkit for Visual Studio.2. In the Download section, choose Toolkit for Visual Studio 2013-2015 to download the installer.3. To start the installation, run the downloaded installer and follow the instructions.NoteBy default, the Toolkit for Visual Studio is installed in the Program Files directory,which requires administrator privileges. To install the Toolkit for Visual Studio as a nonadministrator, specify a different installation directory.Uninstall the Toolkit for Visual StudioUninstall for Visual Studio 2022Uninstall Toolkit for Visual Studio from within Visual Studio 2022 by using the main menu andnavigating to: Extensions Manage Extensions.Uninstall for Visual Studio 2017 and Visual Studio 2019Uninstall the Toolkit for Visual Studio from within Visual Studio by using Tools Extensions andUpdates (Visual Studio 2017) or Extensions Manage Extensions (Visual Studio 2019).Uninstall for Visual Studio 2013 and Visual Studio 2015To uninstall the Toolkit for Visual Studio, you must uninstall the AWS Tools for Windows.1. In Control Panel, open Programs and Features.NoteTo open Programs and Features directly, run appwiz.cpl from a command prompt orthe Windows Run dialog.2. Choose AWS Tools for Windows, and then choose Uninstall.5

AWS Toolkit for Visual Studio User GuideOlder versions of the Toolkit for Visual Studio3. If prompted, choose Yes.Uninstalling the AWS Tools for Windows doesn't remove the Samples directory. This directory ispreserved in case you have modified the samples. You have to manually remove this directory.Older versions of the Toolkit for Visual StudioVisual Studio 2008—Install the Toolkit for Visual Studio 2008 from SToolkitForVisualStudio2008.msi.Visual Studio 2010 and 2012—Install the Toolkit for Visual Studio for Visual Studio 2010 and 2012 g AWS credentialsBefore you can use the Toolkit for Visual Studio, you must provide one or more sets of valid AWScredentials. These credentials allow you to access your AWS resources through the Toolkit for VisualStudio. They're also used to sign programmatic web services requests so that AWS can verify that therequest comes from an authorized source.ImportantAWS credentials consist of an access key ID and secret access key. We recommend that youdo NOT use your account's root credentials. Instead, create one or more IAM users, and thenuse those credentials. For additional information, see Using IAM Users and Best Practices forManaging AWS Access Keys.6

AWS Toolkit for Visual Studio User GuideCredentials locationsCredentials locationsThe Toolkit for Visual Studio supports multiple sets of credentials from any number of AWS accounts.Each credentials set is referred to as a profile. The Toolkit for Visual Studio works with profiles stored inthe following locations: Shared AWS files: By default, these files are located in the .aws directory in your home directoryand are named config and credentials. (The location of your home directory varies based on theoperating system, but is referred to using the environment variables %UserProfile% in Windows and HOME or (tilde) in Unix-based systems.)Credentials stored in these files are in plaintext, and are accessible by the AWS CLI and the AWS SDKs.For more information, see Where Are Configuration Settings Stored? in the AWS Command LineInterface User Guide. SDK Store: On Windows systems, the SDK Store is another place to create profiles and store encryptedcredentials for your AWS for .NET applications. It's located in ccounts.json. You can use the SDK Store during development as analternative to the shared AWS credentials file.Credentials stored here are encrypted on your machine, and are specific to your Windows user account.They can't be decrypted or used elsewhere.For more information, see Configuring AWS credentials in the AWS SDK for .NET Developer Guide.Options for configuring credentialsTo work with AWS services using the Toolkit for Visual Studio, you need to configure at least onecredential profile that's available in either the shared AWS credentials file or the SDK Store.For options for obtaining the necessary access keys and adding them to a profile that's stored in either ashared AWS credentials file or SDK Store, see Creating profiles for your AWS credentials (p. 7). Andyou can enhance your access credentials by adding entries to profiles that define how to use AWS SingleSign-On (AWS SSO) (p. 11) and multi-factor authentication (MFA) (p. 12).Topics Creating profiles for your AWS credentials (p. 7) Using AWS SSO credentials in AWS Toolkit for Visual Studio (p. 11) Using multi-factor authentication (MFA) in Toolkit for Visual Studio (p. 12) Using external credentials (p. 15)Creating profiles for your AWS credentialsConfiguring access credentials for Toolkit for Visual Studio involves obtaining access keys and addingthose keys to a set of credentials called a profile. You can store multiple profiles in shared AWScredentials files or in the SDK Store.You've several options for adding profiles to your AWS credentials: Using the AWS Explorer interface available in the Toolkit for Visual Studio Editing the credentials file with a text editor Creating a profile with the aws configure command7

AWS Toolkit for Visual Studio User GuideCreating profiles for AWS credentialsObtaining access keys for your profileToolkit for Visual Studio allows you to interact with a wide range of AWS services, so you should ensurethat the IAM entity that's used has the necessary permissions to interact with those services. Youcan allow Toolkit for Visual Studio to access your AWS services by manually creating your own set ofcredentials called a profile. Profiles feature long-term credentials called access keys, which you canobtain from the IAM console.NoteThe following procedure shows how you can use the IAM console to create access keys. Youcan also manage access keys using AWS CLI commands and AWS API operations. For moreinformation, see Managing access keys for IAM users in the IAM User Guide.To obtain access keys for a profile1.To get your access keys (consisting of an access key ID and secret access key), go to the IAM consoleat https://console.aws.amazon.com/iam/.2.Choose Users from the navigation bar and then choose your AWS user name (not the check box).3.Choose the Security credentials tab, and then choose Create access key.NoteIf you already have an access key but you can't access your secret key, make the old keyinactive and create a new one.4.In the dialog box that shows your access key ID and secret access key, choose Downloa

Studio is supported for Visual Studio versions 2017 and later. For details about how to download and install the kit, see Install the Toolkit for Visual Studio (p. 4). Note The Toolkit for Visual Studio was also released for Visual Studio 2008, 2010, 2012, 2013, and 2015 versions. Howe