Skip to content

Instantly share code, notes, and snippets.

@HVHO
Created August 29, 2021 07:21
Show Gist options
  • Save HVHO/e6a40f6a795d5cad26732ed184362297 to your computer and use it in GitHub Desktop.
Save HVHO/e6a40f6a795d5cad26732ed184362297 to your computer and use it in GitHub Desktop.
resource "aws_instance" "example" {
ami = "ami-0ba5cd124d7a79612"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.instance.id]
user_data = <<-EOF
#!/bin/bash
echo "Hello, World" > index.html
nohup busybox httpd -f -p 8080 &
EOF
tags = {
Name = "terraform-example"
}
}
resource "aws_security_group" "instance" {
name = "terraform-example-instance"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment