Search code examples
amazon-web-servicesamazon-s3aws-cli

AWS CLI listing all the files within a S3 Bucket


I am practicing AWS commands. My client has given me the AWS IAM access key and the secret but not the account that I can log in to the admin panel. Those keys are being used with the project itself. What I am trying to do is that I am trying to list down all the files recursive within a S3 bucket.

This is what I have done so far.

I have configured the AWS profile for CLI using the following command

aws configure

Then I could list all the available buckets by running the following command

 aws s3 ls

Then I am trying to list all the files within a bucket. I tried running the following command.

 aws s3 ls s3://my-bucket-name

But it seems like it is not giving me the correct content. Also, I need a way to navigate around the bucket too. How can I do that?


Solution

  • You want to list all of the objects recursively but aren't using --recursive flag. This will only show prefixes and any objects at the root level

    Relevant docs https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/ls.html