question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NodeJS AWS SDK The specified bucket does not exist (also weird `aws s3 ls` behavior)

See original GitHub issue

Server is running via docker like:

docker run -e initialBuckets=bucket-1,bucket-2 -e root=/tmp/buckets -p 9090:9090 -p 9191:9191 -v /tmp/buckets:/tmp/buckets -t adobe/s3mock

(Version running is 2.1.18, which is latest as of this writing)

Im able to:

  • Upload a Dockerfile
  • Confirm I can download it again
  • Confirm I can see the item listed with list-objects-v2
aws --endpoint-url http://localhost:9090 s3 cp Dockerfile s3://bucket-1/Dockerfile
aws --endpoint-url http://localhost:9090 s3 cp s3://bucket-1/Dockerfile ./s
aws --endpoint-url http://localhost:9090 s3api list-objects-v2 --bucket bucket-1

Heres where the bugs start:

  • aws --endpoint-url http://localhost:9090 s3 ls bucket-1 isnt showing anything other than: image

  • NodeJS aws-sdk’s AWS.S3.putObject is always throwing “NoSuchBucket: The specified bucket does not exist” (with the server printing “Responding with status 404: The specified bucket does not exist.”)

  • AWS.S3.listObjectsV2 isnt listing anything

My NodeJS S3 is configured like:

new aws.S3({
    accessKeyId: globals.AWS_ACCESS_KEY,
    secretAccessKey: globals.AWS_SECRET_KEY,
    endpoint: 'http://localhost:9090'
})

where the access and secret keys are just empty strings right now

My listObjectsV2 is:

const opts = {Bucket: 'bucket-1'}
const response = await s3.listObjectsV2(opts).promise()

My putObject is:

const obj = {
Bucket: 'bucket-1',
Body: 'some string',
Key: 'some-key'
}
await s3.putObject(obj).promise()

Let me know if I can provide any more info. Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
yonilernercommented, Jan 4, 2020

After more digging, it seems like I may be able to force the desired behavior with s3ForcePathStyle: true in the S3 SDK config

1reaction
timoecommented, Jan 3, 2020

thx for reporting, looks like a Bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS s3 api error: specified bucket does not exist
The error is stating that bucket does not yet exist. By the looks of your code, the bucket name is not correct, which...
Read more >
Resolve S3 Access Denied errors when using an AWS SDK
I can access my Amazon Simple Storage Service (Amazon S3) resources when I use the AWS Command Line Interface (AWS CLI).
Read more >
Class: Aws::S3::Client — AWS SDK for Ruby V3
Creates or modifies OwnershipControls for an Amazon S3 bucket. Applies an Amazon S3 bucket policy to an Amazon S3 bucket. Creates a replication...
Read more >
Troubleshoot IAM-related Access Denied errors in Amazon S3
If your bucket policy has this condition, the IAM user must access your bucket from the allowed IP addresses. Check for a condition...
Read more >
get-object — AWS CLI 1.27.28 Command Reference
If the object you request does not exist, the error Amazon S3 returns depends on whether you also have the s3:ListBucket permission.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found