Skip to content

Instantly share code, notes, and snippets.

@heitorlessa
Created August 30, 2016 14:18
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save heitorlessa/5b709df96ea6ac5ddc600545c0683d3b to your computer and use it in GitHub Desktop.
Save heitorlessa/5b709df96ea6ac5ddc600545c0683d3b to your computer and use it in GitHub Desktop.
Minio with python boto3
# Sample as to how to initialize s3 client to work with Minio API compatible - https://github.com/minio/minio
# AWS CLI counterpart - https://docs.minio.io/docs/aws-cli-with-minio
import boto3
s3 = boto3.resource('s3',
endpoint_url='http://<minio_IP>:9000',
config=boto3.session.Config(signature_version='s3v4')
)
@alfonsrv
Copy link

If credentials are not stored in ~/.aws/credentials location, boto3 must be parametrized like this instead, so it doesn't attempt to acquire a session token at AWS' endpoint

s3_target = boto3.resource('s3', 
    endpoint_url='https://<minio>:9000',
    aws_access_key_id='<key_id>',
    aws_secret_access_key='<access_key>',
    aws_session_token=None,
    config=boto3.session.Config(signature_version='s3v4'),
    verify=False
)

@mo-pyy
Copy link

mo-pyy commented Feb 24, 2023

you don't need to set verify=False unless you didn't setup TLS for minio

@gnkow
Copy link

gnkow commented Jun 17, 2023

I know this gist is old, but is there any way to use ./aws/credentials (including token) to be authenticated in minio?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment