Get into Terraform

  1. Write a comparison between Ansible Vs Docker Vs Terraform :
  • Terraform
    • Terraform focuses on infrastructure automation, and interprets a model described in Hashicorp Configuration Language. Terraform has Immutable infrastructure. Terraform Specializes in infrastructure provisioning. Terraform provides Lifecycle aware.  Maintains state of deployments.
  • Ansible
    • Ansible takes an imperative or procedural approach, which is familiar to anyone experienced in scripting. Ansible has Mutable infrastructure. Ansible gives Limited support for infrastructure provisioning. There is no lifecycle awareness in Ansible.
  • Docker
    • Docker is a Storage/Volume Management ,Orchestration and Schedulers. Docker has Mutable infrastructure. Docker Specializes in infrastructure provisioning.

2. Write a terraform script where you create a linux ec2 instance with Security group and key defined so you should be able to use key to login to ec2 instance :

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "3.49.0"
provider "aws" {
  region  = "us-west-2"
  secret_key = "28fnBcbwMWIoAZ7iDQH+lbiGlpDvQLUFLxHLfhYO"

resource "aws_instance" "Anubhab" {
  ami           = "ami-03d5c68bab01f3496"
  instance_type = "t2.micro"