diff --git a/IaC/aws/terraform/ec2.tf b/IaC/aws/terraform/ec2.tf index 7ae848a..ef7a4fd 100644 --- a/IaC/aws/terraform/ec2.tf +++ b/IaC/aws/terraform/ec2.tf @@ -4,15 +4,27 @@ data "aws_ssm_parameter" "ubuntu22" { resource "aws_instance" "ec2example" { ami = data.aws_ssm_parameter.ubuntu22.value - instance_type = "t3.small" + instance_type = "t3.medium" availability_zone = "eu-west-1a" subnet_id = aws_subnet.subnet.id vpc_security_group_ids = [aws_security_group.sec_group.id] 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 240" + ] + } + provisioner "local-exec" { command = "ansible-playbook -i '${self.public_ip},' ${path.module}/../../ansible/apache.yml" } + connection { + type = "ssh" + user = "ubuntu" + host = self.public_ip + } }