Deploying A Web Application To AWS

In my previous article I shared basics of Amazon Web Services (AWS) and guided through the process of registering to AWS free tier.

While going to work on how to deploy web applications to AWS the first question come to my mind that “Wait, am I going to get billed for this?” So I figured it out by searching on Google for a while that “No, not if I stick to the "Free Tier" offerings.” So don’t worry about the billing if you've chosen Free tier plan of AWS.

Getting ready

Introduction to AWS

Subscription to AWS

AWS toolkit for Visual Studio – I will explain how to get and set it.

Visual Studio – I will be using 2015.

Install AWS toolkit for Visual Studio:

Go to AWS toolkit for Visual Studio,
aws
Download the SDK and install.

To check whether it is installed in Visual Studio or not open visual studio – View.

If you see AWS Explorer that means AWS toolkit installed.

explorer

Creating Project in Visual Studio:

Create new MVC project.

Click on New Project – Web-Asp.Net Web Application,

new

Rename the application and click on ok.

On next screen you have the choice to choose web application type. I am choosing MVC with No Authentication.

Authentication

Choose your web application type and click on ok.

mvc

Application is ready now.

code

Do some editing if you want. I am a lazy guy so I am just leaving the application as it is and moving ahead to deploy the application.

So, right click on project and click on Publish to AWS.

publish

On next screen is for publishing to AWS Elastic Beanstalk.

AWS Elastic Beanstalk

Currently there is no account profile so we have to create one first.

For that first go to AWS dashboard and under Security & Identity category click on IAM,

iam

Now on IAM dashboard first we willbe  required to create a Group,

create

Give a proper name to group,

group

Don’t attach any policy to group just click on Next Step.

next

And create group,

create group
Ok now you have a group just click on group you have created. It will show there are no users in the group. So we will be required to create a user. Click on Users which is on left hand side menu. Then click on Create new users.

Create new users

You can add multiple users at a time but I am just creating one. So just enter user name and click on create.

create

Now we will get the details we are going to use in AWS Publish wizard to deploy our application. Download the credentials and save at accessible location.

Download

Finally we have access key and secret key.

secret key

Now go back to visual studio on Publish to AWS Elastic Beanstalk wizard and click on Add another account profile.

profile

New screen will pop up to fill the profile credential. Fill all the details.

Profile name – as you wish, Access key and secret access key - which we got when we created user, Account number- optional.

Click ok once you've filled all the fields.

profile

Now we have a profile by which we are goingto deploy our application to AWS. Now make sure the profile we have created is selected and Create a new application environment is selected. Click on next.

publish

On this screen you have to select environment or you can enter your own as per requirement. I am choosing test as I am just testing this.

Now enter the URL. URL will be extended by AWS default URL .elasticbeanstalk.com like we get for Azure application.

You will notice that whatever unique URL you are entering is still showing error “Error during URL validation; check URL and try again”. It’s strange. I have spent much time on this part and finally got the solution. I have intentionally let this error come to make you understand why this is happening.

url

We are getting this error because of the missing settings while creating new user on AWS dashboard. So let’s fix it.

Go to AWS dashboard – IAM – Users and click on the user you have created.

dashboard

We are getting the error because we have created a user but didn’t assign any permission or policies which are required for every user we will create. So keep that in mind!

Once you clicked on user you have created it will take you to user page like below.

attach

Click on Attach Policy.

We have to give full access to user to AmazonEC2FullAccess & AWSElasticBeanstalkFullAccess,

access
attach

Once you select both the policies click on Attach Policy,

atatch
Finally we have access to policies we are requiring for the user.

user

We are done with AWS dashboard now go to Visual Studio screen where we had left and click on back and next again.

You will notice URL is showing valid now.

url

Just click on next now.

next

On this screen we are not doing anything for now. Just click next.

On next screen also we are not going to do anything as of now. Just click next.

next

Again Click on Next.

next

Click on finish and on next screen just click deploy.

deploy

You are done. Now next everything will be done by AWS.

It will take time to finish the deployment. Every event will be shown to you like below.

time

When AWS complete its work it will show all event with its status and show below result with link to our application.

application

Test the application:

Go to the URL we had entered at the time of deployment.

It’s working!!

application
So finally we deployed application to AWS. You can find your files uploaded on AWS on

AWS dashboard – S3

dashboard
dashboard

That’s all for this article. I tried to make it simpler and clearer to understand to every professional level – from beginners to expert – but still if you find any difficulty please let me know. I will be happy to help you.

In the next article I will be taking you through the process of assigning a domain to application deployed on AWS.

Keep learning!! Keep sharing!! Keep caring.
 
Read more articles on Visual Studio:

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now