In today’s era of cloud computing, managing and provisioning resources manually is not only time-consuming but can also lead to inconsistencies. Infrastructure as Code (IaC) offers a solution to this challenge. By leveraging IaC tools like Terraform, we can automate, replicate, and version-control our infrastructure setups. In this task, we’ll harness the power of Terraform to create an Amazon S3 bucket and subsequently add a folder within it. This not only showcases the ease of use and flexibility of Terraform but also the seamless integration with cloud services like Amazon S3.

provider "aws" {
  region = "us-west-1"  # Change this to your preferred AWS region
}

resource "aws_s3_bucket" "bucket" {
  bucket = "inouttestappliedsolutionz" # replace inouttestappliedsolutionz with your bucketname
  acl    = "private"  # This will create a private bucket

  versioning {
    enabled = true
  }
}

output "bucket_arn" {
  value = aws_s3_bucket.bucket.arn
}

Now run these two commands.

Initialize Terraform

terraform init

Apply Configuration

terraform apply

Leave a Reply

Your email address will not be published. Required fields are marked *