Erstellen Sie in IAM Standard-, Entwickler- und Produktbenutzer. Hängen Sie die AmazonS3FullAccess-Richtlinie an dev an, um den Zugriff auf S3 zu ermöglichen. Bereiten Sie Bucket1, Bucket2, Bucket3 in S3 vor.
Anmeldeinformationsdatei
~/.aws/credentials
or C:\Users\USER_NAME\.aws\credentials
[default]
aws_access_key_id = DEFAULT_ID
aws_secret_access_key = SECRET_KEY1
[dev]
aws_access_key_id = DEV_ID
aws_secret_access_key = SECRET_KEY2
[prod]
aws_access_key_id = PROD_ID
aws_secret_access_key = SECRET_KEY3
Python-Programm
import boto3.session
dev_sess = boto3.session.Session(profile_name='dev')
s3 = dev_sess.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name)
Python-Programm
import boto3.session
dev_sess = boto3.session.Session(
aws_access_key_id='DEV_ID',
aws_secret_access_key='SECRET_KEY2')
s3 = dev_sess.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name)
bucket1
bucket2
bucket3
ClientError: An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied
ProfileNotFound: The config profile (foo) could not be found