S3 Bucket Using terraform AWS part →11

2 min readMay 9, 2023

#75daysofa ws

Terraform Setup video link in windows →https://youtu.be/HboB9FEC6RM

  1. Install Terraform: First, you need to install Terraform on your local machine. You can download the Terraform binary from the official website (terraform.io) and follow the installation instructions for your operating system.
  2. Set up your working directory: Create a new directory on your local machine where you want to store your Terraform configuration files.
  3. Create a Terraform configuration file: Inside your working directory, create a new file with a .tf extension (e.g., main.tf). This file will contain your Terraform code for creating the S3 bucket
  4. Write the Terraform code: Open the main.tf file in a text editor and write the following code to define your S3 bucket:
terraform {
required_version = ">= 0.12" # Specify the required version of Terraform
provider "aws" {
region = "your_region" # Replace "your_region" with the AWS region of your choice
resource "aws_s3_bucket" "my_bucket" {
bucket = "your_bucket_name" # Replace "your_bucket_name" with a unique name for your bucket
# Additional optional configuration settings can be added here, such as access control, encryption, etc.
  1. Initialize Terraform: Open a terminal or command prompt, navigate to your working directory, and run the command terraform init. This command initializes Terraform and downloads the necessary plugins and modules.
  2. Plan the infrastructure changes: Run the command terraform plan. Terraform will examine your configuration files, detect the changes you've made, and provide a summary of what resources will be created.
  3. Create the S3 bucket: Run the command terraform apply. Terraform will apply the changes defined in your configuration file and create the S3 bucket in AWS. It will prompt you to confirm the action. Type "yes" and press Enter to proceed.
  4. Verify the S3 bucket: Once the Terraform command completes successfully, you can go to the AWS Management Console or use the AWS CLI to verify that the S3 bucket has been created.

Remember to replace the placeholder values (your_region and your_bucket_name) in the Terraform code with your desired AWS region and a unique bucket name.

This simplified guide outlines the basic steps to create an S3 bucket using Terraform. There are more advanced features and options available in Terraform for managing infrastructure, which you can explore further in the Terraform documentation or seek additional guidance as needed.




Cloud computing and DevOps Engineer and to be as a fresher I am learning and gaining experiance by doing some hands on projects on DevOps and in AWS OR GCP