Setting up PostgreSQL on AWS

The first thing you must do is create an AWS account. Go ahead and create one now by following this link: https://portal.aws.amazon.com/billing/signup#/start . Once you have signed up, login into the AWS console and head over to the Amazon Relational Database Service (RDS) (from the navigation bar, click Services | Database | RDS). Once taken to the RDS dashboard, click on Get Started Now:

You will be navigated to the Launch DB instance web page. Here you will need to make some selections pertaining to the DB setup. Select PostgreSQL as the DB engine to be used:

Ensure to check the Only enable options eligible for RDS Free Usage Tier checkbox. Navigate to the next set of setup procedures by clicking Next. On the next page, leave the instance specifications as is and input the necessary DB settings. Input a DB instance name, master username, and master password. We used messenger-api as our DB instance name, you may choose to use another name of your choice. Regardless your choice, ensure that you take note of all inputs you make. Once you are done entering the necessary, continue to the next screen.

You will be navigated to the Configure advanced settings screen. In the Network & Security section, ensure to enable public accessibility and select the Create new VPC security group option under VPC Security Groups.  Scroll down to the Database options section of the screen and enter a DB name. Once again, we used MessengerDB as the DB name. Leave the remaining options as they are and click Launch DB instance at the end of the web page:

Your DB instance will be created by AWS. The creation process may take up to 10 minutes so it may be a good idea to take a coffee break at this point.

After waiting a little while, click View DB instance details. This will take you to a page where you can see detailed information on your just deployed DB instance. Scroll to the Connect section of the page to view the connection details of the DB instance:

We need these details to successfully connect to the MessengerDB on this PostgreSQL DB instance. To enable messenger-api to connect to MessengerDB, you must edit the spring.datasource.urlspring.datasource.username, and spring.datasource.password properties in the application.properties file. After doing this, application.properties should look similar to the following:

spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:postgresql://<endpoint>/MessengerDB
spring.datasource.username=<master_username>
spring.datasource.password=<password>

The final thing we will do is deploy the messenger API to an Amazon EC2 instance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.255.178