Skip to content

Commit

Permalink
chore: Update Apache playbook in AWS EC2 Terraform configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nilgaar committed Jul 13, 2024
1 parent 0e99df0 commit 3c66e26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions IaC/ansible/apache.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Install and start Apache
hosts: all
become: yes
Expand Down
15 changes: 11 additions & 4 deletions IaC/aws/terraform/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 3c66e26

Please sign in to comment.