Skip to content

Instantly share code, notes, and snippets.

@p120ph37
Last active July 21, 2023 18:37
Show Gist options
  • Save p120ph37/ec9856ec04189ca7f0fccd71d6841396 to your computer and use it in GitHub Desktop.
Save p120ph37/ec9856ec04189ca7f0fccd71d6841396 to your computer and use it in GitHub Desktop.
MinIO S3 in Alpine with instance-IAM-role credentials
# Using AWS instance IAM role to provide credentials to minio-client cli.
# Works in Alpine 3.18+ (the minio-client package is not available in 3.17)
# Should also work anywhere else minio, curl, and jq can run.
# Provides a very-lightweight way to access S3 from Alpine
apk add minio-client curl jq
export MC_HOST_s3=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ | head -1) | jq -r '"https://\(.AccessKeyId):\(.SecretAccessKey):\(.Token)@s3.amazonaws.com"')
mcli ls s3/mybucket
# See:
# https://github.com/minio/mc/blob/master/docs/minio-client-complete-guide.md#rotating-credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment