Hello guys hope you are doing good 🙂
From the past few days I was suffering to deploying my ASP.NET MVC application integrated with Angular 4 + PostgreSQL DB into AWS. After my serious deliberation I’ve goto know the procedure and wanted my friends to know about this. That might help you in future.
Step1: Create Elastic Beanstalk web application in AWS
- Once you login into your account you can find the “Build a solution” section below
- Choose on Build a web app
- To create a new Application click on Create New Application, and fill the following required fields Application Name & Platform (.Net). And click on “Create application” button which will start creating the application
- Once application is created with Environments, then you must be able to see Health – Green
- Now make sure that the user which is going to be used has the following permissions.
Step2: Create RDS (Postgres) in AWS
- Go to RDS service, and choose PostgreSQL from Step1
- Click on Next, in Step2 choose your case Production (or) Dev / Test
- Provide the required details
- DB instance Class (1GB/ 2GB/…..)
- DB Instance Name
- Master Username & Password
- Now make sure that your instance is publicly accessible – Yes, if not click on Modify in Details Section. And choose Public accessible – Yes. If it is not public accessible we will be not able to access this Database in PgAdmin.
Step3: Deploy the application into AWS
- Firstly we need to install “AWS toolkit for Visual Studio 2017”. Once installed you can see the option “Publish to AWS Elastic Beanstalk” on right click the project.
- Select “Publish to AWS Elastic Beanstalk”, it ask you to create Account Profile.
- To get the Access Key Id & Secret Access Key, Go to IAM in AWS Console.
- Select the user, then go to “Security Credentials”, where we can create the Access Key.
- Once you create a new Access key, it gives you Access Key ID & Secret Access Key. Make sure to store your Secret Access Key in a secured place.
- Now go back to VS 2017 and enter your credentials.
- Now you can see the Web App we have created in AWS Console.
- Now Go to View Open AWS Explorer Amazon EC2 Key Pairs Create key pair
- Creating a new Key Pair, will give you a <Key Pair Name>.pem
- Select “Publish to AWS Elastic Beanstalk”, after selecting profile click on Next.
- In the Application Options section add the key value pair. And click Next
- Now click Deploy
Step4: Check database connections
- Open PgAdmin4
- Get the Host Name from the AWS Console RDS Instances Copy the End Point (Host Name)
- Now create New Server Enter the Credentials of RDS.
- Create your tables required for the application.
Step5: Install Angular Packages in EC2 instance using Remote Desktop
- Go to EC2 Service
- Click on “Instances”
- Find your instance and right click on it, then choose “Get Windows Password”
- Now it will ask you to upload “Key Pair Path” Get the <Key Pair Name>.pem file that we have created when deploying the Web App.
- Once you upload it will generate the Password, make sure to store it a secured directory.
- Now you can connect to the Remote desktop using that password.
- Once you have connected go to C:\\inetpub\\wwwroot.
- Open command prompt for wwwroot directory.
- Download Node from the https://nodejs.org/en/ .
- Now in the command prompt type “npm install”, this will install the packages required for angular.
- Now run the application