Creating AWS resources in four ways using AWS Console, CLI, CloudFormation and Terraform!

This blog post will show you how to create an S3 bucket in AWS using four ways using AWS Management Console, AWS Cloudformation and Terraform!

Let us begin!

First Way: Directly using S3 Management Console

Go to AWS management console > Go to S3 Service

Click on create bucket button and provide details for the bucket you want to create, as shown in below pics:

There you go, you can see bucket is created!

Second Way: Using Cloudformation Stack in AWS Management Console

Cloudformation is AWS native Infrastructure as a Code (IaaC) service.

We write yaml or JSON scripts to create and configure AWS resources.

Using Cloudformation we can create Stacks by uploading the script. The resources mentioned in the script are created inside the Stack as shown in below:

Third Way: Using AWS CLI

To create a stack using AWS CLI you run the aws cloudformation create-stack command. You must provide the stack name, the location of a valid template, and any input parameters.

//Creating a Stack
$ aws cloudformation create-stack --stack-name mystack --template-body file://Desktop/xyz.yml
//Deleting a Stack
$ aws cloudformation delete-stack --stack-name mystack

As shown below you can create and delete your stack:

aws cli command create a stack
cloudformation console showing stack created
s3 console showing bucket created with stack
aws cli command to delete the created stack

Fourth Way: Using Terraform

[To install and configure Terraform, see this post]

Let us create a resource like a S3 bucket! Simple and easy!

Create file

provider "aws" {
  profile    = "default"
  region     = "ap-south-1"

resource "aws_s3_bucket" "b" {
  bucket = "bucket_name_here"
  acl    = "private"

  tags = {
    Name        = "Env"
    Environment = "Dev"

$ terraform init command which initializes various local settings and data that will be used by subsequent commands.

The terraform init command will automatically download and install any Provider binary for the providers in use within the configuration, which in this case is just the aws provider:

$ terraform apply command

In the same directory as the file you created, run terraform apply.

This output shows the execution plan, describing which actions Terraform will take in order to change real infrastructure to match the configuration. 

Provide input as YES to apply the execution plan of creating the bucket

Check your AWS S3 console to verify

Ok, here it is! The end of post! Hope this helps! 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s