Determine if Postgres is running on AWS RDS

Determine if Postgres is running on AWS RDS
Photo by Kevin Ku / Unsplash

I found 3 ways to check if the current instance of Postgres is running on AWS

select * from pg_settings where name like 'rds.%';
select * from pg_settings where name like 'aurora%';
select spcname from pg_tablespace where spcname like 'aurora%';

Using the first method to check for any settings that start with rds.

select * from pg_settings where name like 'rds.%'

Returns around 40 rows that look like this

name settings
rds.global_db_rpo -1
rds.internal_databases rdsadmin

The second method is pretty much the same as the first but you'll get less rows back, around 9.

select * from pg_settings where name like 'aurora%';
name settings
aurora_compute_plan_id on
aurora_stat_plans.calls_until_recapture 0
aurora_stat_plans.with_triggers off

The final method is to check if there are any tablespaces that are specific to AWS

select spcname from pg_tablespace where spcname like 'aurora%';
spcname
aurora_temp_tablespace

I'm sure there are more ways but this should work for me. If you know of any others feel free to reach out and I'll add them.