I am running localstack through docker and have enabled SQS and S3 for this test. Additionally, I am invoking my Lambda through AWS SAM local, in a docker container. The following Python code to access localstack SQS through Boto3 works perfectly:
import boto3
sqs = boto3.client('sqs',
endpoint_url="http://docker.for.mac.localhost:4576",
use_ssl=False,
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY)
print sqs.list_queues()
However, when I try to use S3 instead, like so:
s3 = boto3.client('s3',
endpoint_url="http://docker.for.mac.localhost:4572",
use_ssl=False,
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
region_name='us-east-1')
print s3.list_buckets()
I get the error: An error occurred (NoSuchBucket) when calling the ListBuckets operation: The specified bucket does not exist: NoSuchBucket. I've made sure that the ports are correct and that through the normal aws local CLI I can manage S3 in localstack, so I have absolutely no idea as to what would be causing this. If anyone knowledgeable with AWS SAM/localstack S3/boto3 could give me some insight I would greatly appreciate it.
Thanks for reporting @zachschultz . My assumption would be that this is related to the difference between domain-style addressing and path-style addressing in S3. See also the note in the Troubleshooting section of the README.
Can you try changing the configuration to use path-style addressing: http://boto3.readthedocs.io/en/latest/guide/s3.html#changing-the-addressing-style
Hope that helps.
Hey @zachschultz, are you sure that there is a bucket in your localstack's S3 instance?
I ask because I had this same issue before I created any buckets.
Here are the steps I took:
$ aws configure set default.s3.addressing_style path
$ aws --endpoint-url=http://localhost:4572 s3api create-bucket --bucket mybucket --region us-west-1
$ aws --endpoint-url=http://localhost:4572 s3api put-object --bucket mybucket --key foobar123 --body bin/myscript.bash
Resources:
@whummer and @Phrohdoh thank you both! That did it
Most helpful comment
Hey @zachschultz, are you sure that there is a bucket in your localstack's S3 instance?
I ask because I had this same issue before I created any buckets.
Here are the steps I took:
Resources:
aws configureaws s3api create-bucketaws s3api put-object