forked from JesseHoch/learn-terraform-github-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
56 lines (45 loc) · 1023 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.26.0"
}
random = {
source = "hashicorp/random"
version = "3.0.1"
}
}
required_version = "~> 1.0"
backend "remote" {
organization = "REPLACE_ME"
workspaces {
name = "REPLACE_ME"
}
}
}
provider "aws" {
region = "us-east-1"
}
resource "random_pet" "sg" {}
resource "aws_instance" "web" {
ami = "ami-09e67e426f25ce0d7"
instance_type = "t2.micro"
vpc_security_group_ids = [aws_security_group.web-sg.id]
user_data = <<-EOF
#!/bin/bash
echo "Hello, World" > index.html
nohup busybox httpd -f -p 8080 &
EOF
}
resource "aws_security_group" "web-sg" {
name = "${random_pet.sg.id}-sg"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
output "web-address" {
value = "${aws_instance.web.public_dns}:8080"
}