Create a PostgreSQL Server Using AWS EC2
  • Introduction
  • AWS EC2: Launching Instance
    • Overview
    • Create Security Group
    • Create Launch Template
    • Option 1: Create Auto Scaling Group
    • Option 2: Create a Single Instance
    • Attach Elastic IP Address
  • Ubuntu 20.04: Configuring PostgreSQL
    • Overview
    • Install PostgreSQL
    • Add Role to PostgreSQL Server
    • Allow Remote Connection
  • Remote Server: Accessing Server on Local Computer
    • Overview
    • Connect with pgAdmin4
    • Connect with Python API
  • AWS EC2: Backup Server
    • Overview
    • Configuring Automatic Backups
  • Next Steps
Powered by GitBook
On this page

Was this helpful?

  1. AWS EC2: Launching Instance

Attach Elastic IP Address

Attach an elastic IP address to your PostgreSQL server instance

PreviousOption 2: Create a Single InstanceNextOverview

Last updated 4 years ago

Was this helpful?

If our master instance is stopped, the instance will be assigned a new public IP address. This can be very inconvenient because we would constantly have to check what our new IP address is in order to access our server.

To avoid this problem, we'll assign an elastic IP address to our master instance in the auto scale group.

To create an elastic IP address,

  1. Navigate to your AWS EC2 dashboard.

  2. Under "Network & Security", select "Elastic IPs".

  3. Under "Elastic IP Address settings" and "Public IPv4 address pool", leave the default option "Amazon's pool of IPv4 addresses"

  4. Tags (Optional): If you'd like, you can associate your PostgreSQL tag with your Elastic IP address.

  5. Select "Allocate"

After being brought back to the "Elastic IPs" page,

  1. In the green box that says "Elastic IP address allocated successfully", select "Associate this Elastic IP address"

  2. Under "Resource type", leave the default option: "Instance"

  3. Under "Instance", select the master instance of your auto scale group

  4. Under "Private IP address", select an IP address

  5. Under reassociation, leave the box unchecked

Note about reassociation: Having the elastic IP be reassociated means that if the instance with the elastic IP address in your auto group fails, the IP address would be reassociated with the instance that replaces the failed one.

For our case, if our master instance fails, it would be best if the elastic IP address is simply dissociated. Then, we can use a backup (discussed in a later chapter) to recreate our master instance and reattach the elastic IP address to the backup.