AWS CLI 👶🏼vs CFT👨🏼vs Terraform😈

AWS CLI 👶🏼vs CFT👨🏼vs Terraform😈

It is very important to know the difference between them

In this Blog we are going to learn what is AWS CLI , CFT and Terraform and also differences and comparisons between them , and also we are going to learn the best-scenario to use them.

What is AWS CLI ?

AWS CLI (Command Line Interface) is a unified tool to manage AWS services via command-line commands, enabling automation, scripting, and interaction with AWS resources programmatically for administration and development purposes.

  • How to Install and use it :

    1.You need to go to AWS CLI downloads page.

    2.And then install on it ,on your OS .

    3.Then open the Terminal and you need to authenticate to AWS using AWS Configure Command.

    4.Then it will ask you Secret , Access key, Region and Output format.

    5.Get all the details from Account > Security Credentials > Access Key and Create it.

    6. Then verify that you are authenticated using the following commads, which will list you the buckets in your account

  •     aws s3 ls
    

What is CFT(Cloud Formation Template)?

CFT (CloudFormation Templates) are declarative JSON or YAML files used to define and provision AWS infrastructure resources as code, enabling automated, repeatable, and version-controlled deployments on the AWS platform.

  • How to Use it?

    1.Go to AWS console and then in Services type in CFT.

    2.Go to it ,as earlier in CLI , this CFT acts a middle-ware between User and AWS API.

    3.You need to write all your requirements (like version, description, metadata ..) but the most important thing is resource what you need to create on aws using CFT.

    4.We usually write the requirements in JSON and also YAML, YAML is more preferable because of it s readability .

    5.As a beginner , it very difficult to create this infrastructure file, Use Designer Template(which makes your life easy) where you just need to search for resource and drag it , below you will get the code related to it.

What is Terraform?

Terraform is an open-source Infrastructure as Code (IaC) tool that automates the provisioning and management of cloud infrastructure across multiple providers using a declarative configuration language, enhancing scalability and reproducibility.

How to Use it?

1.It is also similar to CFT, but it supports different providers.

2.You can install terraform , or you can just use terraform in Codespaces.

3.Create a code-space and then in top you will be having search Icon, search for or type in >DEV , you will get Add dev container Configuration files click it, and then click on modify your configuration and type in aws and terraform and it will added , and then the code space will also be restarted.

4.To check whether AWS and terraform is installed , use aws --version ,it should give the version and terraform --version it should also give u version.

Note: you also need to authenticate with AWS, to Authenticate it , go with aws configure.

5.Create a file called main.tf and paste the code below , through which will create EC2 on AWS.

resource "aws_instance" "example" {
  ami                     = "ami-0dcc1e21636832c5d"
  instance_type           = "t2.micro"
}

6.Go to terminal and give terraform init -> which initialises terraform and then terraform apply which creates infrastructure by taking ref of main.tf.

7.To verify it, go to console , EC2, check whether the instance is created or not.

8.Delete it using terraform destroy.

Differences between CLI, CFT &Terraform

AWS CLICFTTerraform
Abstraction LevelCLI operates at the lowest level, allowing direct interaction with AWS services through commands.CFT abstracts infrastructure as code, defining resources and dependencies using JSON or YAML templates.Terraform abstracts infrastructure as a configuration language, enabling multi-cloud provisioning and managing resources across providers.
Resource ManagementCLI provides granular control over individual resources, suitable for manual operations and scripting.CFT allows declarative provisioning of entire stacks and environments, facilitating versioning and automation.Terraform offers a broader scope, managing infrastructure as code with support for dependency management, state tracking, and reusable modules.
Portability and EcosystemCLI is specific to AWS and its services.CFT is tightly integrated with AWS, leveraging native services and a rich repository of templates.Terraform is provider-agnostic, supporting multi-cloud deployments and third-party services, with a thriving ecosystem and community support beyond AWS.

Scenarios:

  • AWS CLI ->(Simpler actions)

    AWS CLI is best for ad-hoc tasks, scripting, and one-off operations where direct control and flexibility are needed, such as resource management, automation, and troubleshooting in AWS environments.

  • CFT -> (Creating and Managing Infra)
    CloudFormation Templates (CFT) are ideal for defining and managing entire AWS infrastructure stacks and environments as code.

  • Terraform

    Terraform is best suited for orchestrating multi-cloud deployments, managing complex infrastructure configurations, and enabling infrastructure as code practices with reusable modules and state management, enhancing scalability and reproducibility.

Thank you.