Terraform

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.0"
    }
	 github = {
      source  = "integrations/github"
      version = "~> 4.0"
    }
  }
}
provider "aws" {
  region     = "us-west-2"
  access_key = "AKIAYIMEDZZZKEPKRNEM"
  secret_key = "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"
}
resource "aws_instance" "first-ec2" {
  ami           = "ami-0dc8f589abe99f538" # us-west-2
  instance_type = "t2.micro"
  
  tags = {
    Name = "Anusha"
  }
}
resource "aws_security_group" "default" {
  name = "rds_sg"
  
  
}

Write a comparison between Ansible Vs Docker Vs Terraform

AttributeTerraformAnsible
Tool categoryOrchestrationConfiguration management
ApproachImmutable infrastructureMutable infrastructure
LanguageDeclarativeImperative
ProvisioningSpecializes in infrastructure provisioningLimited support for infrastructure provisioning
LIfecycle managementLifecycle aware.  Maintains state of deployments.No lifecycle awareness
Command line operationYesYes
AgentlessYesYes
  • Ansible is a powerful server and a configuration management tool, while Docker gives more flexibility in terms of providing modern and innovative options. The outreach of DevOps has made giant strides and Kubernetes being one of the important tools that have provided for portability, extensions, and self-smart processes most importantly. Terraform is the easiest to understand.
  • Docker is particularly a container technology while Ansible and Kubernetes are tools for configuration management.
  • Ansible works with Python while Docker and Kubernetes work with Go.
  • Also, while Ansible and Docker are very user-friendly and easy to manage Kubernetes needs a lot of preparations in terms of planning and manual installation.
  • Docker has multi-components, while Ansible works well with front end developers. Moreover, Kubernetes is much more modern in its applications.
  • Kubernetes thus remains a complex mechanism to work upon nonetheless very helpful however Docker is appealing in the way it handles most of the work.