I’m just getting started with boto3 and AWS. I found this article and tried the sample code. I don’t know if the sample code is wrong or if I need to be looking at something else. The bottom line is that the ‘for’ loop outputs nothing and I do not get any errors. Apparently ‘s3.buckets.all()’ returns nothing. Is there a better, more accurate tutorial for getting started with boto3? TIA.
import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name)
The first result is expected: it means you have credentials configured correctly.
The second result says you have no buckets in your AWS account.
Yes, you’ll need S3 buckets set up to have something to list. You can create one for no cost using boto3’s S3 client: docs. I would recommend disabling ACLs by setting ObjectOwnership="BucketOwnerEnforced" (using IAM instead)
Thanks for the reply again. I think I now understand the problem. My mturk and AWS accounts are not linked. I can find instructions on how to link an existing nmturk account to a new AWS account and how to link an existing AWS account to a new mturk account. For some reason there is nothing on how to link an existing AWS account to and existing mturk account.
I think I figured out how to link existing accounts but I don’t know how to tell if it worked. I get the same output using the credentials given after I supposedly linked the accounts.