Skip to content

Commit 16d1362

Browse files
author
Matthew Fisher
committed
Merge pull request #48 from bacongobbler/hotfix-s3-region
fix(docker-entrypoint-initdb.d): fixup envvar evaluation
2 parents 5808c18 + dc85344 commit 16d1362

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

rootfs/docker-entrypoint-initdb.d/001_setup_envdir.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
cd "$WALE_ENVDIR"
44

55
# access-key-id and access-secret-key files are mounted in via kubernetes secrets
6+
AWS_ACCESS_KEY_ID=$(cat access-key-id)
7+
AWS_SECRET_ACCESS_KEY=$(cat access-secret-key)
8+
AWS_DEFAULT_REGION="us-east-1"
9+
BUCKET_NAME="dbwal"
10+
611
if [ "$DATABASE_STORAGE" == "s3" ]; then
712
AWS_ACCESS_KEY_ID=$(cat /var/run/secrets/deis/objectstore/creds/accesskey)
813
AWS_SECRET_ACCESS_KEY=$(cat /var/run/secrets/deis/objectstore/creds/secretkey)
914
AWS_DEFAULT_REGION=$(cat /var/run/secrets/deis/objectstore/creds/region)
1015
BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-bucket)
11-
echo $AWS_ACCESS_KEY_ID > AWS_ACCESS_KEY_ID
12-
echo $AWS_SECRET_ACCESS_KEY > AWS_SECRET_ACCESS_KEY
13-
echo $BUCKET_NAME > BUCKET_NAME
1416
else
15-
AWS_ACCESS_KEY_ID=$(cat access-key-id)
16-
AWS_SECRET_ACCESS_KEY=$(cat access-secret-key)
17-
AWS_DEFAULT_REGION="us-east-1"
18-
BUCKET_NAME="dbwal"
17+
# these only need to be set if we're not accessing S3 (boto will figure this out)
1918
echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > WALE_S3_ENDPOINT
2019
echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > S3_URL
21-
cp access-key-id AWS_ACCESS_KEY_ID
22-
cp access-secret-key AWS_SECRET_ACCESS_KEY
23-
echo $BUCKET_NAME > BUCKET_NAME
2420
fi
2521

22+
echo $AWS_ACCESS_KEY_ID > AWS_ACCESS_KEY_ID
23+
echo $AWS_SECRET_ACCESS_KEY > AWS_SECRET_ACCESS_KEY
24+
echo $AWS_DEFAULT_REGION > AWS_DEFAULT_REGION
25+
echo $BUCKET_NAME > BUCKET_NAME
26+
2627
# setup envvars for wal-e
2728
echo "s3://$BUCKET_NAME" > WALE_S3_PREFIX
2829

@@ -36,24 +37,23 @@ aws_access_key_id = $AWS_ACCESS_KEY_ID
3637
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
3738
EOF
3839

39-
# HACK (bacongobbler): minio *must* use us-east-1 and signature version 4
40-
# for authentication.
41-
# see https://github.com/minio/minio#how-to-use-aws-cli-with-minio
4240
if [ "$DATABASE_STORAGE" == "s3" ]; then
43-
cat << EOF > /root/.aws/config
41+
cat << EOF > /root/.aws/config
4442
[default]
4543
region = $AWS_DEFAULT_REGION
4644
EOF
4745
else
48-
cat << EOF > /root/.aws/config
46+
# HACK (bacongobbler): minio *must* use us-east-1 and signature version 4
47+
# for authentication.
48+
# see https://github.com/minio/minio#how-to-use-aws-cli-with-minio
49+
cat << EOF > /root/.aws/config
4950
[default]
5051
region = $AWS_DEFAULT_REGION
5152
s3 =
5253
signature_version = s3v4
5354
EOF
5455
fi
5556

56-
5757
# write AWS config to postgres homedir as well
5858
cp /root/.aws/* /home/postgres/.aws/
5959
chown -R postgres:postgres /home/postgres

0 commit comments

Comments
 (0)