From 65173ba26d776fe13573b52ad4688243b917dc05 Mon Sep 17 00:00:00 2001 From: Daniel Sinclair Date: Thu, 17 Oct 2019 03:58:23 -0400 Subject: [PATCH 1/3] added AWS_S3_ENDPOINT env option for products like DigitalOcean Spaces --- README.md | 1 + entrypoint.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 4549a49..a69a4f5 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ The following settings must be passed as environment variables as shown in the e | `AWS_ACCESS_KEY_ID` | Your AWS Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) | `secret` | **Yes** | N/A | | `AWS_SECRET_ACCESS_KEY` | Your AWS Secret Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) | `secret` | **Yes** | N/A | | `AWS_S3_BUCKET` | The name of the bucket you're syncing to. For example, `jarv.is`. | `secret` | **Yes** | N/A | +| `AWS_S3_ENDPOINT` | The endpoint URL of the bucket you're syncing to. Can be used for VPC scenarios or for S3 compliant products like [DigitalOcean Spaces](https://www.digitalocean.com/community/tools/adapting-an-existing-aws-s3-application-to-digitalocean-spaces). | `env` | No | AWS | | `AWS_REGION` | The region where you created your bucket in. For example, `us-east-1`. [Full list of regions here.](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions) | `env` | **Yes** | N/A | | `SOURCE_DIR` | The local directory you wish to sync/upload to S3. For example, `./public` | `env` | No | `.` | | `DEST_DIR` | The directory inside of the S3 bucket you wish to sync/upload to. Eg: `my_project/assets`. | `env` | No | `/` | diff --git a/entrypoint.sh b/entrypoint.sh index 9b39635..b6e7a48 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,6 +24,7 @@ fi # Default to syncing entire repo if SOURCE_DIR not set. SOURCE_DIR=${SOURCE_DIR:-.} +ENDPOINT_APPEND=${"--endpoint-url $AWS_S3_ENDPOINT":-} # Create a dedicated profile for this action to avoid # conflicts with other actions. @@ -39,4 +40,5 @@ EOF # All other flags are optional via `args:` directive. sh -c "aws s3 sync ${SOURCE_DIR} s3://${AWS_S3_BUCKET}/${DEST_DIR} \ --profile s3-sync-action \ + ${ENDPOINT_APPEND} \ --no-progress $*" From 5ac34c7999c9cf4736b149aeab5e7216e783a067 Mon Sep 17 00:00:00 2001 From: Daniel Sinclair Date: Thu, 17 Oct 2019 04:01:52 -0400 Subject: [PATCH 2/3] reordered documented env variables --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a69a4f5..f6fe487 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ The following settings must be passed as environment variables as shown in the e | `AWS_ACCESS_KEY_ID` | Your AWS Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) | `secret` | **Yes** | N/A | | `AWS_SECRET_ACCESS_KEY` | Your AWS Secret Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) | `secret` | **Yes** | N/A | | `AWS_S3_BUCKET` | The name of the bucket you're syncing to. For example, `jarv.is`. | `secret` | **Yes** | N/A | -| `AWS_S3_ENDPOINT` | The endpoint URL of the bucket you're syncing to. Can be used for VPC scenarios or for S3 compliant products like [DigitalOcean Spaces](https://www.digitalocean.com/community/tools/adapting-an-existing-aws-s3-application-to-digitalocean-spaces). | `env` | No | AWS | | `AWS_REGION` | The region where you created your bucket in. For example, `us-east-1`. [Full list of regions here.](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions) | `env` | **Yes** | N/A | +| `AWS_S3_ENDPOINT` | The endpoint URL of the bucket you're syncing to. Can be used for VPC scenarios or for S3 compliant products like [DigitalOcean Spaces](https://www.digitalocean.com/community/tools/adapting-an-existing-aws-s3-application-to-digitalocean-spaces). | `env` | No | AWS | | `SOURCE_DIR` | The local directory you wish to sync/upload to S3. For example, `./public` | `env` | No | `.` | | `DEST_DIR` | The directory inside of the S3 bucket you wish to sync/upload to. Eg: `my_project/assets`. | `env` | No | `/` | From 069063f70647fe9bacd9d333969f2c490dd9c19d Mon Sep 17 00:00:00 2001 From: Daniel Sinclair Date: Thu, 17 Oct 2019 04:27:47 -0400 Subject: [PATCH 3/3] altered how endpoints are appended --- entrypoint.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b6e7a48..cf0ae48 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,9 +22,14 @@ if [ -z "$AWS_REGION" ]; then exit 1 fi +# Default to CLI defined AWS endpoint +ENDPOINT_APPEND="" +if [ "$AWS_S3_ENDPOINT" ]; then + ENDPOINT_APPEND="--endpoint-url $AWS_S3_ENDPOINT" +fi + # Default to syncing entire repo if SOURCE_DIR not set. SOURCE_DIR=${SOURCE_DIR:-.} -ENDPOINT_APPEND=${"--endpoint-url $AWS_S3_ENDPOINT":-} # Create a dedicated profile for this action to avoid # conflicts with other actions. @@ -39,6 +44,5 @@ EOF # Use our dedicated profile and suppress verbose messages. # All other flags are optional via `args:` directive. sh -c "aws s3 sync ${SOURCE_DIR} s3://${AWS_S3_BUCKET}/${DEST_DIR} \ - --profile s3-sync-action \ - ${ENDPOINT_APPEND} \ + --profile s3-sync-action ${ENDPOINT_APPEND} \ --no-progress $*"