-
Notifications
You must be signed in to change notification settings - Fork 21
/
ec2.tf
38 lines (37 loc) · 1.06 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
data "aws_ami" "windows-ami" {
filter {
name = "name"
#values = ["amzn2-ami-amd-hvm-2.0.20230727.0-x86_64-gp2"]
values = ["Windows_Server-2019-English-Full-Base-2023*"] // for linux "amzn2-ami-amd-hvm-2.0.20230727.0-x86_64-gp2"
}
filter {
name = "platform"
values = ["windows"]
}
filter {
name = "platform"
values = ["windows"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
most_recent = true
owners = ["amazon"]
}
data "aws_caller_identity" "current" {}
resource "aws_instance" "app-server" {
instance_type = "t3.medium"
ami = data.aws_ami.windows-ami.id
vpc_security_group_ids = [aws_security_group.instance-sg.id]
subnet_id = aws_subnet.private.id
associate_public_ip_address = false
iam_instance_profile = aws_iam_instance_profile.ec2_profile.name
user_data = templatefile("user_data/user_data.tpl",
{
Password = "${aws_ssm_parameter.ec2_password.value}"
})
tags = {
Name = "${var.name}-server-1"
}
}