DEV Community

El Morjani Mohamed
El Morjani Mohamed

Posted on

3 1

πŸš€ Mastering AWS S3 with the CLI: A Simple Guide to Creating & Managing Buckets πŸ’»

As developers, we often find ourselves managing cloud storage. AWS S3 is a popular choice due to its flexibility, scalability, and security. Here's a quick breakdown of how to create, configure, and manage an S3 bucket using AWS CLI! πŸ‘‡

πŸ› οΈ Steps to Create and Manage a Bucket:

  1. Create a new S3 bucket in your desired region:
   aws s3api create-bucket --bucket devops22-cli-bucket --region eu-north-1 --create-bucket-configuration LocationConstraint=eu-north-1
Enter fullscreen mode Exit fullscreen mode
  1. List your buckets to ensure it's created successfully:
   aws s3 ls
Enter fullscreen mode Exit fullscreen mode
  1. Secure your bucket by blocking all public access:
   aws s3api put-public-access-block --bucket devops22-cli-bucket --public-access-block-configuration "BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true"
Enter fullscreen mode Exit fullscreen mode
  1. Upload files into your S3 bucket (like images or documents):
   aws s3api put-object --bucket devops22-cli-bucket --content-type image/jpeg --key s3Devops22.jpg --body /path/to/your/image.jpg
Enter fullscreen mode Exit fullscreen mode
  1. Manage permissions to control public or private access to your files. For instance, making an object publicly readable:
   aws s3api put-object-acl --bucket devops22-cli-bucket --key s3Devops22.jpg --acl public-read
Enter fullscreen mode Exit fullscreen mode
  1. Delete files or buckets when no longer needed:
   aws s3api delete-object --bucket devops22-cli-bucket --key s3Devops22.jpg
   aws s3api delete-bucket --bucket devops22-cli-bucket --region eu-north-1
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Why use AWS CLI for S3?

The AWS CLI provides a fast, scriptable interface for managing your resources efficientlyβ€”whether you're creating, securing, or optimizing your buckets. It's ideal for developers who want control and automation in their cloud workflows.

Let’s keep sharing tips and improving our DevOps skills! πŸ”₯

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay