Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions startupscript/aws/install-postgres-client.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# install-postgres-client.bash
#
# Installs or upgrades the PostgreSQL client in the app container.
#

readonly SQL_CLIENT_VERSION="16"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make this into a feature?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, it looks like a feature exists ... let me go that route.


LSB_RELEASE="$(lsb_release -cs)"
readonly LSB_RELEASE

# 1. Download the official PostgreSQL signing key
# This ensures the authenticity of the packages we are about to install.
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
--output /usr/share/keyrings/postgresql-keyring.asc

# 2. Add the PostgreSQL Apt repository to the sources list
echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.asc] http://apt.postgresql.org/pub/repos/apt ${LSB_RELEASE}-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list

# 3. Update the package index
# This refreshes the list of available packages from the newly added repository.
apt-get update -qq

# 4. Install the correct version of client tools
# This includes psql, pg_dump, and pg_restore.
apt-get install -y "postgresql-client-${SQL_CLIENT_VERSION}"
5 changes: 5 additions & 0 deletions startupscript/aws/post-startup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ fi
########################################################
source "${CLOUD_SCRIPT_DIR}/configure-aws-vault.sh"

###############################################################################
# Install or upgrade the postgres client for use with Aurora Postgres instances
###############################################################################
source "${CLOUD_SCRIPT_DIR}/install-postgres-client.bash"

#################################################
# Write common environment vars to user's .bashrc
#################################################
Expand Down