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

El Morjani Mohamed - Sep 29 - - Dev Community

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! ๐Ÿ”ฅ

. . . . . .
Terabox Video Player