#!/bin/bash -xe amazon-linux-extras install postgresql11 -y yum install postgresql-server postgresql-devel postgresql-contrib -y postgresql-setup initdb systemctl enable postgresql.service --now sudo -u postgres createdb ${DatabaseName} sudo -u postgres psql -U postgres -c "CREATE ROLE ${DatabaseUser} WITH LOGIN PASSWORD '${DatabasePassword}'" sudo -u postgres psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE ${DatabaseName} TO ${DatabaseUser}" echo 'host all all 0.0.0.0/0 password' > /var/lib/pgsql/data/pg_hba.conf echo 'local all all password' >> /var/lib/pgsql/data/pg_hba.conf echo "listen_addresses = '*'" >> /var/lib/pgsql/data/postgresql.conf systemctl restart postgresql.service