# Configuring AWX with external AWS Postgres RDS

**URL:** <https://forum.ansible.com/t/configuring-awx-with-external-aws-postgres-rds/4134>\
**Category:** Get Help\
**Tags:** collections, awx, aws\
**Created:** [February 29, 2024, 10:14am UTC](https://forum.ansible.com/t/configuring-awx-with-external-aws-postgres-rds/4134 "2024-02-29T10:14:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aj-kyriba](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/aj-kyriba/32/2409_2.png) [@aj-kyriba](https://forum.ansible.com/u/aj-kyriba)\
**Post date:** [February 29, 2024, 10:14am UTC](https://forum.ansible.com/t/configuring-awx-with-external-aws-postgres-rds/4134/1 "2024-02-29T10:14:04Z")

</div>

Hello

I am trying to install AWX 23.8.0 in a AWS EC2 and want to use external Aws Postgres RDS(Engine 1).

I followed the documentation in [awx/tools/docker-compose/README.md at 22.5.0 · ansible/awx · GitHub](https://github.com/ansible/awx/blob/22.5.0/tools/docker-compose/README.md)  
And I configured

```auto
# External Database Settings
 pg_host="awx-pg-12.qsdsdqq000.eu-west-3.rds.amazonaws.com"
 pg_password=" *****"
 pg_username="postgres"
 pg_hostname="awx-pg-12" #DB-IDentifier

```

and during the installation the job fails

```auto
tools_awx_1 | 2024-02-29 09:46:06,251 ERROR [-] awx.main.cache_clear Encountered unhandled error in cache clear main loop
tools_awx_1 | Traceback (most recent call last):
tools_awx_1 | File "/awx_devel/awx/main/management/commands/run_cache_clear.py", line 22, in handle
tools_awx_1 | with pg_bus_conn() as conn:
tools_awx_1 | File "/usr/lib64/python3.9/contextlib.py", line 119, in __enter__
tools_awx_1 | return next(self.gen)
tools_awx_1 | File "/awx_devel/awx/main/dispatch/ __init__.py", line 132, in pg_bus_conn
tools_awx_1 | pg_connection.connect()
tools_awx_1 | File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
tools_awx_1 | return func(*args, **kwargs)
tools_awx_1 | File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/base/base.py", line 270, in connect
tools_awx_1 | self.connection = self.get_new_connection(conn_params)
tools_awx_1 | File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner
tools_awx_1 | return func(*args, **kwargs)
tools_awx_1 | File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/django/db/backends/postgresql/base.py", line 275, in get_new_connection
tools_awx_1 | connection = self.Database.connect(**conn_params)
tools_awx_1 | File "/var/lib/awx/venv/awx/lib64/python3.9/site-packages/psycopg/connection.py", line 728, in connect
tools_awx_1 | raise ex.with_traceback(None)
tools_awx_1 | psycopg.OperationalError: connection failed: database "awx" does not exist

```

Doesnt the Awx installation manage the creation of default DB during installation?

When I tried previously with the default config, the Posgtes container was created and all the required DB was installed.

I tested the accessibility of RDS endpoint from EC2 running AWX and its OK.

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [February 29, 2024, 12:10pm UTC](https://forum.ansible.com/t/configuring-awx-with-external-aws-postgres-rds/4134/2 "2024-02-29T12:10:11Z")

</div>

Hi, you should manually create `awx` database if you want to use external DB.

The official `postgres` container image creates default DB during its first startup by referring `POSTGRES_USER` or `POSTGRES_DB` environment variables.

This is why `awx` database is created for bundled PSQL by default, since the default value for `POSTGRES_DB` is `awx`.

> `POSTGRES_USER`
> 
> This optional environment variable is used in conjunction with `POSTGRES_PASSWORD` to set a user and its password. This variable will create the specified user with superuser power and a database with the same name.
> 
> [https://hub.docker.com/\_/postgres](https://hub.docker.com/_/postgres)

> `POSTGRES_DB`
> 
> This optional environment variable can be used to define a different name for the default database that is created when the image is first started. If it is not specified, then the value of `POSTGRES_USER` will be used.
> 
> [https://hub.docker.com/\_/postgres](https://hub.docker.com/_/postgres)

---

<div class="post-metadata">

**Author:** ![Rtwolfe94022](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rtwolfe94022/32/2463_2.png) [@Rtwolfe94022](https://forum.ansible.com/u/Rtwolfe94022)\
**Post date:** [March 1, 2024, 3:04am UTC](https://forum.ansible.com/t/configuring-awx-with-external-aws-postgres-rds/4134/3 "2024-03-01T03:04:29Z")

</div>

The AWX installation does not automatically create the database on an external AWS RDS instance. You need to manually create the “awx” database on your RDS instance before running the AWX installation. Ensure the database connection details in the AWX configuration match your RDS settings and that your EC2 instance can connect to the RDS instance over the network.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 31, 2024, 3:04am UTC](https://forum.ansible.com/t/configuring-awx-with-external-aws-postgres-rds/4134/4 "2024-03-31T03:04:58Z")

</div>

Closed on March 31, 2024, 3:04am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
