I found people is having difficulties when working with Amazon Linux packages because the lack of documentation, including myself !
So I write down the “dead easy” steps to install PostgresSQL on AWS Amazon Linux 2 instance.
OK, let’s go !!!
1. Update your system
sudo yum update -y
2. Enable PostgreSQL in AMZ extra repository
I’m installing PostgreSQL v11, you can change it to the version you want to use in your system
sudo amazon-linux-extras enable postgresql11

3. Install Postgres & dependencies libs
Note that we don’t need version number in the install command
sudo yum install -y postgresql-libs postgresql-server postgresql postgresql-devel
4. Init Postgres DB
sudo postgresql-setup --initdb

5. Start Postgres server, at this point everything is ready to use !
# Set "autostart" Postgres on system startup
sudo systemctl enable postgresql
# Start Postgres
sudo systemctl start postgresql
6. Check Postgres status
sudo systemctl status postgresql

Happy tinkering !