-
Notifications
You must be signed in to change notification settings - Fork 21
/
ec2.tf
54 lines (52 loc) · 1.26 KB
/
ec2.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
resource "aws_security_group" "web-pub-sg" {
name = "allow_inbound_access"
description = "allow inbound traffic"
vpc_id = aws_vpc.this.id
ingress {
description = "from library ip range"
from_port = "3389"
to_port = "3389"
protocol = "tcp"
cidr_blocks = ["147.219.191.0/24"]
}
egress {
cidr_blocks = ["0.0.0.0/0"]
from_port = "0"
protocol = "-1"
to_port = "0"
}
tags = {
"Name" = "app-1-ec2-sg"
}
}
data "aws_ami" "windows-ami" {
filter {
name = "name"
values = ["Windows_Server-2019-English-Full-Base-2023*"]
}
filter {
name = "platform"
values = ["windows"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
most_recent = true
owners = ["amazon"]
}
resource "aws_instance" "app-server" {
instance_type = "t2.micro"
ami = data.aws_ami.windows-ami.id
vpc_security_group_ids = [aws_security_group.web-pub-sg.id]
subnet_id = aws_subnet.public.id
key_name = "skundu-sandbox"
associate_public_ip_address = true
user_data = templatefile("user_data/user_data.tpl",
{
ServerName = var.ServerName
})
tags = {
Name = var.ServerName
}
}