From 3c66e2687685058f4c9e3bd816fa927693259eb5 Mon Sep 17 00:00:00 2001 From: Nil Date: Sun, 14 Jul 2024 00:48:31 +0200 Subject: [PATCH] chore: Update Apache playbook in AWS EC2 Terraform configuration --- IaC/ansible/apache.yml | 1 + IaC/aws/terraform/ec2.tf | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/IaC/ansible/apache.yml b/IaC/ansible/apache.yml index 1728955..0428125 100644 --- a/IaC/ansible/apache.yml +++ b/IaC/ansible/apache.yml @@ -1,3 +1,4 @@ +--- - name: Install and start Apache hosts: all become: yes diff --git a/IaC/aws/terraform/ec2.tf b/IaC/aws/terraform/ec2.tf index b664101..4481933 100644 --- a/IaC/aws/terraform/ec2.tf +++ b/IaC/aws/terraform/ec2.tf @@ -11,13 +11,20 @@ resource "aws_instance" "ec2example" { associate_public_ip_address = true key_name = aws_key_pair.ec2_key_pair.key_name + provisioner "remote-exec" { + inline = [ + "echo 'Waiting for instance to be fully ready...'", + "sleep 60" # Waits for 60 seconds; adjust this value based on your typical EC2 start up time + ] + } + provisioner "local-exec" { command = "ansible-playbook -i '${self.public_ip},' ${path.module}/../../ansible/apache.yml" } - provisioner "remote-exec" { - inline = [ - "echo 'Waiting for instance to be ready'" - ] + connection { + type = "ssh" + user = "ubuntu" + host = self.public_ip } }