Skip to content

Instantly share code, notes, and snippets.

@AnqiZhou26
Created December 17, 2022 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnqiZhou26/1a5cb1290a28b9c5285bc46db363db6d to your computer and use it in GitHub Desktop.
Save AnqiZhou26/1a5cb1290a28b9c5285bc46db363db6d to your computer and use it in GitHub Desktop.
# Create ec2 instances
resource "aws_instance" "web1" {
count = var.availability_zones_count
ami = "ami-0cff7528ff583bf9a"
instance_type = "t2.micro"
availability_zone = data.aws_availability_zones.available.names[count.index]
vpc_security_group_ids = [aws_security_group.public_sg.id]
subnet_id = aws_subnet.public[0].id
associate_public_ip_address = true
user_data = <<-EOF
#!/bin/bash
yum update -y
yum install httpd -y
systemctl start httpd
systemctl enable httpd
echo "<html><body><h1>Video Generator</h1></body></html>" > /var/www/html/index.html
EOF
tags = {
Name = "web1_instance"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment