python - Boto3 doesn't use keys from config file -
i want boto3 access , secret key config file instead of hard coding them. on linux server set following environment variable aws_shared_credentials_file
value /app/.aws/credentials
. in /app/.aws/ put file name credentials following content:
[default] aws_access_key_id = abcd aws_secret_access_key = abcd
of course used actual keys instead of abcd.
python:
import boto3 conn = boto3.client('s3', region_name="eu-west-1", endpoint_url="endpoint", aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, config=config(signature_version="s3", s3={'addressing_style': 'path'}))
however says name'aws_access_key_id' not defined
. how can fix it? thanks
edit:
>>> os.environ['aws_shared_credentials_file'] '/app/.aws/credentials'
if have credentials folder aws credentials created, means don't need specify them when instantiating client. following should work:
import boto3 conn = boto3.client('s3', region_name="eu-west-1", endpoint_url="endpoint", config=config(signature_version="s3", s3={'addressing_style': 'path'}))
Comments
Post a Comment