21

With former generation of Amazon Linux, all I needed to do is add the following in .ebextensions in order to use PostgreSQL:

packages:
    yum:
        postgresql93-devel: []

Now when I deploy on EB with the following platform: Python 3.7 running on 64bit Amazon Linux 2/3.0.0

I get the following error on deployment:

[ERROR] Error occurred during build: Yum does not have postgresql93-devel available for installation

Therefore it is impossible to deploy as I need to connect to a PostgreSQL database in RDS.

What config in .ebextensions do I need to do?

eagle28
  • 896
  • 10
  • 19
  • 1
    Amazon Linux 2 moved some packages to `amazon-linux-extras`. That could be one of the things – jordanm Apr 10 '20 at 21:22
  • Amazon Linux 1 did not have `amazon-linux-extras`. Its new to AL2. Here's a good summary: https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras – Cale Sweeney Dec 11 '20 at 15:23

4 Answers4

39

The following works:

packages:
    yum:
        amazon-linux-extras: []

commands:
    01_postgres_activate:
        command: sudo amazon-linux-extras enable postgresql10
    02_postgres_install:
        command: sudo yum install -y postgresql-devel
eagle28
  • 896
  • 10
  • 19
  • 2
    <3 I love you. literally the only thing that does this. I used AL2. I tried putting what you have here as `02_postgres_install` in a config file that would get executed using the packages configuration key (what you did for amazon-linux-extras) and it didn't work. had to be executed as a command. Thank you!! – Nick Brady Aug 03 '20 at 21:01
  • 7
    What is 10 in postgresql10? Is it the RDS's postgres version? Should I state postgresql12 instead of postgresql10 if the postgres version in my RDS is 12.5? – Sergey Zakharov Mar 30 '21 at 21:51
  • 3
    The 10 is the postgres version as found in the amazon-linux-extras list. They don't have a v12 as of this time. – bkunzi01 Mar 21 '22 at 02:16
  • Documentation for AWS [install a software package from the Extras Library](https://aws.amazon.com/premiumsupport/knowledge-center/ec2-install-extras-library-software/) – Miguel Hargreaves Pimenta Aug 07 '22 at 22:06
3

postgresql93-devel is pretty old. The yum PostgreSQL repository starts at 9.5. Depending on your needs you may want to upgrade to at least 9.5. PostgreSQL 12 is the latest production release.

EDIT

As to the comment @jordanm made - that's correct, the AWS Linux 2 environment does have PostgreSQL 9.2.24 available. If you're ok with that version then you can just install postgresql-devel. Change your .ebextensions to just run:

packages:
    yum:
        postgresql-devel: []

This will install the devel package for 9.2.24.

If you'd like something a bit newer, it's apparently a bunch harder. I was unable to get this to work for the devel package. If you change your .ebextensions to contain something like (not tested!):

container_commands:
    command: 'amazon-linux-extras install -y postgresql9.6'

Then you'll get PostgreSQL 9.6 but it does not appear to have the devel package available.

It doesn't look possible to use the RPM's from https://yum.postgresql.org/ as AWS Linux 2 is not supported. Trying CentOS or RHEL gives an error.

Is 9.2 usable for your environment?

stdunbar
  • 16,263
  • 11
  • 31
  • 53
1

Something that helped me with Amazon Linus 1, is the fact that I didn't need to install Postgres at all when plugging in a RDS service and specifying Postgres as the driver. It's just a thought for people having this problem. But maybe just try to not explicitly install Postgres.

I haven't validated which version will be installed by default.

Xen_mar
  • 8,330
  • 11
  • 51
  • 74
0

This configuration works fine with the ElasticBeanstalk environment (Python 3.6 running on 64bit Amazon Linux). After this, I was able to install psycopg2 with requirements.txt

packages:
    yum:
        libicu-devel: []

commands:
    01_postgres_libs:
        command: rpm -ivh --force https://yum.postgresql.org/10/redhat/rhel-6.9-x86_64/postgresql10-libs-10.7-1PGDG.rhel6.x86_64.rpm
    02_postgres_install:
        command: rpm -ivh --force https://yum.postgresql.org/10/redhat/rhel-6.9-x86_64/postgresql10-10.7-1PGDG.rhel6.x86_64.rpm
    03_symink_pg_config:
        command: sudo ln -sf /usr/pgsql-10/bin/pg_config /usr/bin/pg_config
    04_postgres_devel:
        command: sudo rpm -ivh --force https://yum.postgresql.org/10/redhat/rhel-6.9-x86_64/postgresql10-devel-10.7-1PGDG.rhel6.x86_64.rpm
Andrew Saushkin
  • 187
  • 2
  • 11