Skip to content

Commit 4f39c7d

Browse files
authored
Merge pull request #6 from shinitiandrei/session-tokens
update: adding session tokens for temporary credentials for AWS S3
2 parents e5ff6b5 + df86c38 commit 4f39c7d

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM minio/mc:RELEASE.2020-10-03T02-54-56Z
1+
FROM minio/mc:RELEASE.2022-05-04T06-07-55Z
22

33
LABEL maintainer="Peter Evans <mail@peterevans.dev>"
44
LABEL repository="https://github.com/peter-evans/s3-backup"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ The following variables may be passed to the action as secrets or environment va
2828
- `ACCESS_KEY_ID` (**required**) - The storage service access key id.
2929
- `SECRET_ACCESS_KEY` (**required**) - The storage service secret access key.
3030
- `MIRROR_TARGET` (**required**) - The target bucket, and optionally, the key within the bucket.
31+
- `AWS_SESSION_TOKEN` - When using temporary credentials (Amazon S3)
32+
- `AWS_REGION` (required with AWS_SESSION_TOKEN) - the region where the s3 bucket is located for Amazon S3. **Mandatory** when using SESSION_TOKEN.
3133
- `MIRROR_SOURCE` - The source defaults to the repository root. If required a path relative to the root can be set.
3234
- `STORAGE_SERVICE_URL` - The URL to the object storage service. Defaults to `https://s3.amazonaws.com` for Amazon S3.
3335
- `STORAGE_SERVICE_ALIAS` - Defaults to `s3`. See [MinIO Client](https://github.com/minio/mc) for other options such as S3 compatible `minio`, and `gcs` for Google Cloud Storage.

entrypoint.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ set -euo pipefail
33

44
STORAGE_SERVICE_ALIAS=${STORAGE_SERVICE_ALIAS:="s3"}
55
STORAGE_SERVICE_URL=${STORAGE_SERVICE_URL:="https://s3.amazonaws.com"}
6+
AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN:=""}
67
MIRROR_SOURCE=${MIRROR_SOURCE:="."}
8+
AWS_REGION=${AWS_REGION:=""}
79

810
# Set mc configuration
9-
mc alias set "$STORAGE_SERVICE_ALIAS" "$STORAGE_SERVICE_URL" "$ACCESS_KEY_ID" "$SECRET_ACCESS_KEY"
11+
if [ -z "$AWS_SESSION_TOKEN" ]; then
12+
mc alias set "$STORAGE_SERVICE_ALIAS" "$STORAGE_SERVICE_URL" "$ACCESS_KEY_ID" "$SECRET_ACCESS_KEY"
13+
else
14+
export MC_HOST_${STORAGE_SERVICE_ALIAS}=https://${ACCESS_KEY_ID}:${SECRET_ACCESS_KEY}:${AWS_SESSION_TOKEN}@s3.${AWS_REGION}.amazonaws.com
15+
fi
1016

1117
# Execute mc mirror
1218
mc mirror $* "$MIRROR_SOURCE" "$STORAGE_SERVICE_ALIAS/$MIRROR_TARGET"

0 commit comments

Comments
 (0)