πŸš€ DevOps Certified Professional
πŸ“… Starting: 1st of Every Month 🀝 +91 8409492687 | 🀝 +1 (469) 756-6329 πŸ” Contact@DevOpsSchool.com

Terraform script

DevOps

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

write a terraform script which create a ubuntu ec2-instance and copy a ansible playbook, install ansible and run it.

resource "aws_instance "first-ec2" {
ami = "ami-03d5c68bab01f3496" # us-west-2
instance_type = "t2.micro"
key_name  = " jyoshna"
tags = {
   Name = "Jyoshna"
}
connection {
  type = "ssh"
  user = "ubuntu"
  private_key = file("jyoshna")
  #host = aws_instance.web.public_ip
  host = self.public_ip
}
resource "aws_instance" "web"{
provisioner "file" {
  source = "files/getplaybook.sh"
  destination = "/tmp/"  

provisioner "remote.exec" {
inline = {
   " sudo apt-get update"
   " sudo apt-get install ansible-y",
   " sudo start ansible"
  }
}
$ ansible-playbook<playbook.yml>