The purpose of this tutorial is to migrate a sample ASP.NET web application to a fully managed AWS Elastic Beanstalk environment using the interactive Windows Web Application Migration Assistant (WWAMA). Additional information about the Windows Web Application Migration Assistant is available here.
What you will accomplish
In this tutorial, you will migrate a sample ASP.NET web application to a fully managed AWS Elastic Beanstalk environment.
You will need an AWS account and IAM permissions to create an EC2 instance, key pair, security group, IAM user, and an Elastic Beanstalk environment. This tutorial will deploy an AWS CloudFormation template that automatically provisions the sample website on an EC2 instance that will be the source web application for the migration.
Use CloudFormation to launch the EC2 instance that will host the sample website. Then, set up the required IAM permissions.
a. Launch an EC2 instance through CloudFormation
Use CloudFormation to launch an EC2 instance in the US-East-1 Region.
First, you will need to download the YAML file we will use for the CloudFormation template from GitHub. In GitHub, open the context (right-click) menu of the Raw button at the top of the file, select Save Link As. Choose the location on your computer where you want to save the file, and select Save.
Once you have saved the file locally, open the Create stack page within the AWS CloudFormation console. In the Specify template section, select Upload a template file.
Choose the Choose file button and navigate to the YAML file on your local machine and select Open.
Then choose Next.
On the Configure stack options screen, choose Next. At the bottom of the Review screen, choose Submit.
Once the stack has been created, you will see its status change to CREATE_COMPLETE.
b. Create the IAM user
In the left navigation pane, select Users, then choose Add users.
Enter the User name MigrationUser, check the box for Programmatic access, then choose Next:Permissions.
Select Attach existing policies directly, and enter beanstalk in the search bar to filter the policies. Select the checkbox next to AdministratorAccess-AWSElasticBeanstalk.
- Enter iam in the search bar and select the checkbox next to IAMReadOnlyAccess.
- Enter s3 in the search bar and select the checkbox next to AmazonS3FullAccess.
a. Navigate to EC2 console and log in
Once you've logged in, select the WWAMA instance and choose Connect.
Select the RDP client tab, then choose the Download remote desktop file button and save the RDP file. Then choose Get password.
Choose Upload private key file to upload your private key, then choose Decrypt password to get your Windows Server password. You will see the password in plain text. Copy it because you will need it in the next step.
b. Open a PowerShell terminal on the EC2 Windows Server
PS C:\> Import-Module AWSPowerShell PS C:\> Set-AWSCredential -AccessKey ACCESS_KEY -SecretKey SECRET_ACCESS_KEY -StoreAs default
c. Extract the Migration Assistant files
The migration assistant has been pre-downloaded on the C:\ drive by the CloudFormation template. The file is wwama.zip.
Open the context (right-click) menu for the wwama.zip file and extract the archive.
d. View the sample website before migration
Open a web browser on the EC2 Windows Server instance and navigate to http://localhost/. You will see the sample website that the migration assistant will migrate.
a. Launch the MigrateIISWebsiteToElasticBeanstalk.ps1 script
In the PowerShell terminal you opened earlier, change to the migration assistant directory and launch the migration script.
The assistant prompts you for the location of your credentials file. Press Enter to skip.
When prompted for AWS Profile Name, enter default.
1 PS C:\> cd \wwama\windows-web-app-migration-assistant-master 2 PS C:\wwama\windows-web-app-migration-assistant-master> .\MigrateIISWebsiteToElasticBeanstalk.ps1
b. Select AWS Region
Enter the AWS Region where you'd like your Elastic Beanstalk environment to run. For example: us-east-1. For a list of AWS Regions where Elastic Beanstalk is available, see AWS Elastic Beanstalk endpoints and quotas.
Enter the AWS Region (default us-east-1):
c. Select the web application you want to migrate
The assistant then discovers any websites running on your IIS server and lists them, as in the following example.
Enter the number 2 to migrate the sample site.
Enter the number of the website to migrate: (default 1):
d. Update connection strings
The assistant then prompts you to update any connection strings selected above. Press Enter as there aren’t any connection strings in this application.
This message will appear: The migration assistant didn't find any connection strings.
Enter the number of the connection string you would like to update, or press ENTER:
e. Set up your Elastic Beanstalk application
Next, name your new Elastic Beanstalk application.
When prompted to select the Windows Server version, enter 6 and press Enter.
Enter a unique name for your new Elastic Beanstalk application:
1 Enter the instance type (default t3.medium) :
For environment type, enter 1 for single instance.
1 Enter the environment type :
The migration assistant then migrates your application to Elastic Beanstalk.
When the migration completes, you will see a success message in the CLI.
Now that the site is successfully migrated, verify that the website is up and running.
a. Access in web browser
You can get the URL from the output of the PowerShell script.
Input the URL into your web browser, and you should see your web application, now running on Elastic Beanstalk.
b. Access in the Elastic Beanstalk console
You can also view the Elastic Beanstalk environment from the AWS console. Make sure you're seeing the console for the same Region you deployed your application to. Feel free to explore what you can do with your application by using the menu on the left side.
In this final step, you will clean up and delete all of your resources.
a. Delete the Elastic Beanstalk application
Go to the Elastic Beanstalk console. In the Applications view, select the radio button next to your application, choose the Actions menu, then select Delete application. In the confirmation dialog, enter the name of your application and choose Delete. This will delete both your application and the Elastic Beanstalk environment.
b. Delete the CloudFormation stack
Go to the CloudFormation console and delete the CloudFormation stack WWAMAStack created at the start of the lab.
c. Delete temporary files from Amazon S3
Go to the Amazon S3 console, select the radio button next to the bucket named elastic-beanstalk-migration-ACCOUNT_ID-TIMESTAMP, where ACCOUNT_ID is your AWS account ID and TIMESTAMP is the time that your application was deployed. Then choose Empty to first empty the contents of the bucket. You will need to confirm this action by entering permanently delete in a text box and choose Empty. Choose Exit to go back to the S3 buckets view.
Now that the S3 bucket is empty, select the radio button next to the bucket again and choose Delete. You will need to confirm this action by entering the name of the bucket in the text box and choose Delete bucket.
Congratulations! You have successfully migrated a sample ASP.NET web application to a fully managed Elastic Beanstalk environment using the Windows Web Application Migration Assistant (WWAMA).
AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.
You can simply upload your code, and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, auto scaling, to application health monitoring. At the same time, you retain full control over the AWS resources powering your application and can access the underlying resources at any time.
Visit AWS Elastic Beanstalk to learn more.