How to create a folder in AWS S3 bucket?
You can create a folder in S3 bucket either from AWS management console or using AWS API.
Create a new folder in AWS S3 bucket from management console:
- Log in to the AWS management console
- Navigate to your S3 bucket and get inside the bucket.
- Click on “Create folder” to create a new folder.
- Provide a name to the folder and click “Create folder”
Create a new folder in AWS S3 bucket using AWS CLI:
## Create a single folder
aws s3api put-object \
--bucket <YOUR_S3_BUCKET_NAME> \
Additional resource: replicate your entire local directory structure in AWS S3 bucket
You can also upload your entire directory structure in AWS S3 bucket from your local system. In this way you can create multiple folders in AWS S3 bucket at once. You also have option to choose file extension to include or exclude while uploading to S3 bucket.
## Create a multiple files and folders
mkdir -p mydir/mydir1 mydir/mydir2 mydir/mydir3
echo "hello" > mydir/mydir1/myfile.txt
echo "world" > mydir/mydir2/myfile.json
echo "welcome" > mydir/mydir3/myfile.yml
## Copy the files and folders to S3 bucket
aws s3 cp mydir s3://cloudaffaire/ \
## List all your files and folders
aws s3 ls s3://cloudaffaire/ \
## Where cloudaffaire is the bucket name
Note: You cannot create multiple folders (keys) inside your bucket without any files (objects) inside them.
Hope this solves your issue, keep learning and keep sharing.