diff --git a/docs/production/export-and-import.md b/docs/production/export-and-import.md index d03b22773f..571e8a7bf2 100644 --- a/docs/production/export-and-import.md +++ b/docs/production/export-and-import.md @@ -169,7 +169,7 @@ data includes: PostgreSQL server to add: ```ini - s3_region = # region to write to S3 + s3_region = # region to write to S3; defaults to EC2 host's region s3_backups_key = # aws public key s3_backups_secret_key = # aws secret key s3_backups_bucket = # name of S3 backup diff --git a/puppet/zulip/files/postgresql/env-wal-g b/puppet/zulip/files/postgresql/env-wal-g index 91e8112b6b..10cd39d8a0 100755 --- a/puppet/zulip/files/postgresql/env-wal-g +++ b/puppet/zulip/files/postgresql/env-wal-g @@ -4,7 +4,14 @@ if [ -z "$ZULIP_SECRETS_CONF" ]; then fi export PGHOST=/var/run/postgresql/ -AWS_REGION=$(crudini --get "$ZULIP_SECRETS_CONF" secrets s3_region) +AWS_REGION=$(crudini --get "$ZULIP_SECRETS_CONF" secrets s3_region 2>/dev/null) +if [ "$AWS_REGION" = "" ]; then + # Fall back to the current region, if possible + AZ=$(ec2metadata --availability-zone || true) + if [ -n "$AZ" ] && [ "$AZ" != "unavailable" ]; then + AWS_REGION=$(echo "$AZ" | sed 's/.$//') + fi +fi export AWS_REGION AWS_ACCESS_KEY_ID=$(crudini --get "$ZULIP_SECRETS_CONF" secrets s3_backups_key) export AWS_ACCESS_KEY_ID