DevOps(Day-67): AWS S3 Bucket Creation and Management through Terraform

DevOps(Day-67): AWS S3 Bucket Creation and Management through Terraform

TABLE OF CONTENTS

AWS S3 Bucket

Amazon S3 (Simple Storage Service) is an object storage service that offers industry-leading scalability, data availability, security, and performance. It can be used for a variety of use cases, such as storing and retrieving data, hosting static websites, and more.

In this task, you will learn how to create and manage S3 buckets in AWS.

Task: Hands-On

Create an S3 bucket using Terraform

  • Create an S3.tf with required bucket name.

  • Use terraform init and plan to get the providers and view the terraform changes.

  • Now, use terraform apply to make the changes using terraform files.

  • Navigate to the AWS management console and go to S3 to view the bucket created.

Configure the bucket to allow public read access

  • Enable the ACL in the S3 bucket and choose Bucket owner preferred and save the change.

  • Create a public_access.tf file and write proper configuration.

  • Use terraform apply to create public access for the S3 bucket.

  • Check the bucket in the console for the public access which is now enabled.

Create an S3 bucket policy that allows read-only access to a specific IAM user or role

  • Create an IAM.tf file to write the configuration of IAM read access for the S3 bucket.

  • Now, use terraform apply to provide the access in the bucket.

  • Now, check the bucket to view the policy.

Enable versioning on the S3 bucket

  • Insert the versioning configuration in the S3.tf file.
  resource "aws_s3_bucket" "devops_bucket" {
    bucket = "devopsbucketday67"
    versioning {
      enabled = true
    }
  }
  • Use the terraform apply to enable versioning in S3 bucket.

  • We can see the changes in the S3 bucket in the AWS management console.

Thanks for reading my article. Have a nice day.

WRITTEN BY Biswaraj Sahoo --AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes

Empowering communities via open source and education. Connect with me over linktree: linktr.ee/biswaraj333