By using AWS re:Post, you agree to the Terms of Use

I can't use my s3 buckets

0

Hello, i created many buckets for testing and i have the same result, when i contacted the support they said "I tried to list the s3 buckets on your account but there is no s3 bucket created", but i created 3 of them.

I use laravel 8 and an package who many peoples use, i have no error when a seek my user (IAM), but if a write name of my bucket or an bucket name who doesn't exist i have the same result.

i've this errors :

Aws\S3\Exception\S3Exception
Error executing "HeadObject" on "https://mybucketname.s3.eu-west-3.amazonaws.com/images/1/6PepdkQG3ZkfbBWjVr0jhoUotprRc5hMiNC78RE7.png"; AWS HTTP error: Client error: `HEAD https://mybucketname.s3.eu-west-3.amazonaws.com/images/1/6PepdkQG3ZkfbBWjVr0jhoUotprRc5hMiNC78RE7.png` resulted in a `404 Not Found` response NotFound (client): 404 Not Found (Request-ID: BG0058D586NR6CPC) -

i already seek on many forum, and contacted the support but this not really helped me :(

My question is: Why the support don't see my buckets, and how can i a bucket who i can use?

  • What kind of credentials are your using in your laravel? Are you using Instance profile? or IAM user keys? did you try aws cli to check if you can see the bucket using the same set of credentials?

4 Answers
0

Ok thanks ^^, I have no errors :) when i use CLI, only if i search the file but normal, my file is upload by a php form.

$ aws s3api head-object --bucket rankserver --key images/200x100.png
{
    "AcceptRanges": "bytes",
    "LastModified": "2021-12-23T09:55:42+00:00",
    "ContentLength": 737,
    "ETag": "\"948305774cd370326b142c7d5aee2d3d\"",
    "ContentType": "image/png",
    "Metadata": {}
}  

My problem have changed, I can upload a file only if his name is the same of my file in my bucket ( uploaded manally ). ( I can find in the AWS CLI the file uploaded manually)

answered 8 months ago
  • So, if you upload a file manually then you are able to upload a file with the same name using the php form, but if the file is not already in the bucket the upload with the php form fails. Did I understand correctly? If yes, what error do you get from in the php code?

  • Yes its that, I got the same error from my 1 post

    Aws\S3\Exception\S3Exception
    Error executing "HeadObject" on "https://rankserver.s3.eu-west-3.amazonaws.com/images/200x100.png"; AWS HTTP error: Client error: `HEAD https://rankserver.s3.eu-west-3.amazonaws.com/images/200x100.png` resulted in a `404 Not Found` response NotFound (client): 404 Not Found (Request-ID: BG0058D586NR6CPC) -
    
0

Maybe this document can help you. There's a ton of information here on the HeadObject and it's permissions and use. Hope this helps, let me know if it does. https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html

answered 8 months ago
0

Hello bukxy!

You can list the buckets in your account using the AWS CLI command:
aws s3 ls
You should see an output similar to this:

2019-11-26 15:43:45 bucketname1
2021-04-14 16:21:25 bucketname2
2021-04-14 16:13:48 bucketname3
2021-04-15 10:11:33 bucketname4
...

Once you confirmed that you have S3 buckets in your account and the bucket name you expected is in the list, run the following command to verify you have access to the bucket:
aws s3api head-bucket --bucket BUCKETNAME
(Please replace BUCKETNAME with the real bucket name you confirmed with the "aws s3 ls" command.)
If the bucket exists and you have access to it, no output is returned. Otherwise, an error will be shown.
For example:

A client error (404) occurred when calling the HeadBucket operation: Not Found

Once you confirmed the bucket exists and you have access to it, run the following command to check if the file exists:
aws s3api head-object --bucket BUCKETNAME -- key images/1/6PepdkQG3ZkfbBWjVr0jhoUotprRc5hMiNC78RE7.png
(Please replace BUCKETNAME with the real bucket name you confirmed with the "aws s3 ls" command.)
If the file exists you should have an output similar to this:

{  
    "AcceptRanges": "bytes",  
    "LastModified": "2020-12-22T23:43:04+00:00",  
    "ContentLength": 15522,  
    "ETag": "\"XXXXXXXXXXXXXXXXXXXXXXXXX\"",  
    "ContentType": "text/csv",  
    "Metadata": {}  
}

If the file does not exist you should have an output similar to this:

An error occurred (404) when calling the HeadObject operation: Not Found

Here are are a few links to get you started:

  1. Installing the AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
  2. Configuring the AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
  3. Command head-bucket: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/head-bucket.html
  4. Command head-object: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/head-object.html

I hope this helps!

answered 8 months ago
0

You might have a permission error. Do you have cloudtrail logs enabled?

If you do, you can go to the user here, and generate a policy based on the cloudtrail logs: https://console.aws.amazon.com/iamv2/home?#/users

If you don't have cloudtrail enabled, you can find information here on that: https://aws.amazon.com/cloudtrail/

Here a note on what cloudtrail can do for your account this way: https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-generation.html

Let me know if this helps.

answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions