puppet: Default s3_region to the current ec2 region.

This commit is contained in:
Alex Vandiver 2022-03-11 07:11:13 +00:00 committed by Tim Abbott
parent bfdc547b00
commit 19beed2709
2 changed files with 9 additions and 2 deletions

View File

@ -169,7 +169,7 @@ data includes:
PostgreSQL server to add: PostgreSQL server to add:
```ini ```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_key = # aws public key
s3_backups_secret_key = # aws secret key s3_backups_secret_key = # aws secret key
s3_backups_bucket = # name of S3 backup s3_backups_bucket = # name of S3 backup

View File

@ -4,7 +4,14 @@ if [ -z "$ZULIP_SECRETS_CONF" ]; then
fi fi
export PGHOST=/var/run/postgresql/ 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 export AWS_REGION
AWS_ACCESS_KEY_ID=$(crudini --get "$ZULIP_SECRETS_CONF" secrets s3_backups_key) AWS_ACCESS_KEY_ID=$(crudini --get "$ZULIP_SECRETS_CONF" secrets s3_backups_key)
export AWS_ACCESS_KEY_ID export AWS_ACCESS_KEY_ID