Skip to main content

Command Palette

Search for a command to run...

S3 bucket on AWS using Terraform :

Published
β€’2 min read
P

πŸ‘‹ Hello, and welcome to my DevOps journey! πŸš€ I am Priyanka Varshney,πŸ› οΈ As an aspiring DevOps engineer, I'm all about bridging the gap between development and operations, making software delivery seamless and efficient. πŸ’»πŸ”§ On this Hashnode blog, I'll be sharing my learnings, experiences and adventures as I dive deep into the world of continuous integration, automation, and cloud technologies. β˜οΈβš™οΈ Let's connect, learn, and grow as a vibrant DevOps community. Follow my Hashnode blog, and let's embrace the DevOps adventure together! πŸ€πŸ”—

How to create S3 bucket using Terraform | Terraform AWS Cloud Tutorial

In the previous blog we will get to know how to create a resource or file using terraform concept

Now we will make a s3 bucket on AWS using Terraform :

  1. Need to create a EC2 instance and install Terraform by using the previous blog .

  2. Create a file using vim editor vim s3.tf

     resource aws_s3_bucket my_bucket {                                                                                                                                    
                 bucket="varpriya/terraform"
     }
    
  3. Create another terraform file for installing aws terraform provider vim terraform.tf using this file

    •           terraform {
                  required_providers {
                    aws = {
                      source = "hashicorp/aws"
                      version = "5.92.0"
                    }
                  }
                }
      
  4. Then initialize the terraform using command terraform init

  5. Then need to install AWS CLI to connecting with your account.

  6. To install the AWS CLI, run the following commands.

     curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
     unzip awscliv2.zip
     sudo ./aws/install
    

    Note : Need to install the Unzip in order to unzip the file sudo apt-get install unzip

  7. You need to configure the AWS CLI with your AWS EC2 account aws configure

    you will need access key ID

  8. In order to get the access key ID and secret key ID , we will need to create a user from IAM service in AWS

    1. Go to the IAM service and click on users from the Dashboard.

  1. Create a user named Terra-admin and give the permission AmazonS3FullAccess by clicking on attach policies directly.

    1. Click on next and then create user.

Now Terra-admin user is created successfully.

  1. To obtain the access key, navigate to the user profile, select "Security Credentials," create a security key, and then choose the "Command Line Interface (CLI)" option. After that, confirm your action and proceed by clicking "Next."

5. Now you will get two access key ID

  1. Now you can copy paste the keys in your local machine

  2. You can see the all S3 bucket by using the command aws s3 ls

  3. You can apply now to create the S3 bucket.

    Now you can go to the s3 on amazon , you can see the s3 bucket.

Happy learning :)

S3 bucket on AWS using Terraform :