Projects on AWS

Bots Just Got Better

with .NET and the AWS Toolkit for Visual Studio

Module 5: Deployment & Cleanup

In this module you will deploy the chatbot to EC2 using AWS CodeBuild and AWS CodeDeploy as well as clean up resources to avoid charges.


Follow the step-by-step instructions below to deploy the chatbot application and cleanup the resources afterwards. To expand the section, click on each step number.

 Time to Complete

30 minutes

 Services Used

CodeDeploy, CodeBuild, EC2, AWS CodeStar

Implementation Instructions

    • a. From the AWS Console click Services then select CodeStar under Developer Tools.
      b. Click Create a new project and choose ASP.NET Core Web Application template.
      c. Provide “Project Name”, choose CodeCommit as your repository and click Next.
      d. Ensure that “AWS CodeStar would like permission to administer AWS resources on your behalf” is checked and click Create Project.
      e. Select a Key Pair and ensure “I acknowledge that I have access to the private key file for this key pair (mytestkeypair.pem), and that without this file, I won’t be able to log into my instance.” Is ticked.
      f. You can now choose how you want to edit your project code. You can always change this choice but for now click on “Command Line Tools” and follow the setup instructions for your operating system of choice.
      g. In Command Line, if you followed the instructions you would’ve cloned the project repository from CodeCommit.
      h. You can use various products and Git importers, however, in case you don’t have any of those, we will address a quick/manual way of doing this. Take the code you cloned from the github repo in Module 4 and replace all the code in your newly cloned CodeCommit repository with it (make sure to delete all the old code before pasting the .NET Chatbot code).
      i. Get into the cloned directory in command line and proceed to run the following commands:

      1. git add -A
      2. git commit -m "adding Chatbot code"
      3. git push origin master

      j. Click “Skip” and you will be presented with a dashboard of your code going through Continuous Deployment (among many other options which we encourage you to explore).
      k. Under the project directory that houses the Visual Studio Solution file, copy the appspec.yml file and the buildspec.yml.
      l. Under the project directory that houses the Visual Studio Solution file, create a folder and name it scripts.
      m. Copy all the files from the Linux Deployment directory of your cloned repo into the scripts directory created in the previous step.
      n. Click on Application endpoints link to view and test the chatbot application.

      ⚐ NOTE: For additional information, find the documentation located inside the github project.

      ec2 keypair
    • a. Log into your AWS account, ensure that you are in the region us-east-1 (N. Virginia) or eu-west-1 (Ireland).
      b. Log into your GitHub account using your GitHub credentials.
      c. Use AWS CloudFormation to create your infrastructure stack in us-east-1 by clicking the template. You can also download the CloudFormation template here and run the CloudFormation template in the AWS CloudFormation service in the region of your choice.
      d. You will be taken to the AWS CloudFormation console webpage and presented a screen to provide the parameters needed to create your infrastructure resources. Fill in the desired values for the parameters Stack Name and Application.
      e. Open another browser window and go to back to your Github account, click on Settings in GitHub account then clicking on Personal Access Tokens and creating new token with the scopes repo and admin:repo_hook. Be sure to select ALL suboptions for both of the aforementioned scripts.
      f. Go back to the AWS CloudFormation webpage, and fill the GitHubOAuthToken parameter with the value from GitHub generated from previous step.
      g. Select VPC where you want the solution deployed, Public Subnet (the one that has internet gateway attached) that belongs to that VPC.
      h. Select keypair name. For more informaiton about keypair names, click here.
      i. Change instance type if desired, otherwise leave the default value provided.
      j. In OSTtype field select the desired Operating System for the target EC2 instance as Windows and click Next button.
      k. Leave default options for Options and Advanced section and Click Next button.
      l. On the review screen make sure to click the box next to: “I acknowledge that AWS CloudFormation might create IAM resources with custom names.”
      m. Create Stack and watch the full stack and all the necessary resources get created under “Events” tab until the status says CREATE_COMPLETE status.
      n. Take a look at CodePipeline and see the application go through the whole CD/CI process from GitHub to CodeBuild to CodeDeploy which deploys it on EC2 in the end 1.
      o. Once it’s successfully deployed, go to outputs tab in CloudFormation and click on the URL value and see the Chatbot application running in your environment.

      ⚐ NOTE: For additional information, find the documentation located inside the GitHub project.

    • a. Go to the CodeStar page in the console.
      b. Select the elipses in the upper right corner of your project. See screenshot below.
      c. Select the Delete option.
      d. Type the name of your project to confirm deletion. Leave the checkbox next to Delete associated AWS resources along with CodeStar project. Learn more checked.
      e. Hit the Delete button.

      delete codestar project
    • a. Go to the CloudFormation page in the console.
      b. Select your stack.
      c. Go to the Actions drop down menu.
      d. Select the Delete Stack option.
      e. Hit the Yes, Delete button.

  • Lambda
    a. Go to the Lambda page in the console.
    b. Select the function in the list by clicking in the bubble on the left side of the title of it.
    c. Hit actions and click Delete.

    a. Go to the Lex page in the console.
    b. Select the bot in the list by clicking in the bubble on the left side of the title of it.
    c. Hit actions and click Delete.

    a. Go to the Cognito page in the console.
    b. Click Manage Federated Identities.
    c. Click on the federated identity.
    d. Click Edit Identity Pool in the upper right-hand corner.
    e. Scroll down to Delete Identity Pool and click the button. Then confirm by clicking the red delete button.

    ⚐ NOTE: These instructions are also located in the documentation folder inside the GitHub project.


You built an Amazon Lex Chatbot on .NET using Amazon Web Services.

robots salut you

Share your chatbot with friends. We can not wait to see what you are going to build next!