Update main.tf

This commit is contained in:
Ryan Malloy 2024-11-11 08:01:52 +00:00
parent 39e329c99e
commit 55d818834f
1 changed files with 41 additions and 1 deletions

42
main.tf
View File

@ -64,9 +64,49 @@ shutdown -r -t 10;
EOF EOF
} }
# Get latest Windows Server 2012R2 AMI
data "aws_ami" "windows-2012-r2" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["Windows_Server-2012-R2_RTM-English-64Bit-Base-*"]
}
}
# Get latest Windows Server 2016 AMI
data "aws_ami" "windows-2016" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["Windows_Server-2016-English-Full-Base*"]
}
}
# Get latest Windows Server 2019 AMI
data "aws_ami" "windows-2019" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["Windows_Server-2019-English-Full-Base*"]
}
}
# Get latest Windows Server 2022 AMI
data "aws_ami" "windows-2022" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["Windows_Server-2022-English-Full-Base*"]
}
}
# Create EC2 Instance # Create EC2 Instance
resource "aws_instance" "windows-server" { resource "aws_instance" "windows-server" {
ami = data.aws_ami.windows-2019.id ami = data.aws_ami.windows-2022.id
instance_type = var.windows_instance_type instance_type = var.windows_instance_type
subnet_id = aws_subnet.public-subnet.id subnet_id = aws_subnet.public-subnet.id
vpc_security_group_ids = [aws_security_group.aws-windows-sg.id] vpc_security_group_ids = [aws_security_group.aws-windows-sg.id]