You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
968 B
44 lines
968 B
6 months ago
|
variable "http_port" {
|
||
|
description = "Port to listen for HTTP requests on"
|
||
|
default = 8080
|
||
|
type = number
|
||
|
}
|
||
|
|
||
|
output "public_ip" {
|
||
|
value = aws_instance.cloudbuntu.public_ip
|
||
|
description = "The public IP of our new cloudbuntu!"
|
||
|
}
|
||
|
|
||
|
provider "aws" {
|
||
|
region = "us-east-2"
|
||
|
}
|
||
|
|
||
|
resource "aws_instance" "cloudbuntu" {
|
||
|
ami = "ami-0862be96e41dcbf74"
|
||
|
instance_type = "t2.micro"
|
||
|
vpc_security_group_ids = [aws_security_group.cloudwall.id]
|
||
|
|
||
|
user_data = <<-EOF
|
||
|
#!/bin/bash
|
||
|
echo "Hello, World! I'm $(hostname)!" > index.html
|
||
|
nohup busybox httpd -f -p ${var.http_port} &
|
||
|
EOF
|
||
|
|
||
|
user_data_replace_on_change = true
|
||
|
|
||
|
tags = {
|
||
|
Name = "terraform-example"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
resource "aws_security_group" "cloudwall" {
|
||
|
name = "terraform-example.instance"
|
||
|
|
||
|
ingress {
|
||
|
from_port = var.http_port
|
||
|
to_port = var.http_port
|
||
|
protocol = "tcp"
|
||
|
cidr_blocks = ["0.0.0.0/0"]
|
||
|
}
|
||
|
}
|