From 55d818834f0b9a7f0090d8d93f0c7d04ec43d678 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Mon, 11 Nov 2024 08:01:52 +0000 Subject: [PATCH] Update main.tf --- main.tf | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index bb5f7c2..cf9aeb4 100644 --- a/main.tf +++ b/main.tf @@ -64,9 +64,49 @@ shutdown -r -t 10; 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 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 subnet_id = aws_subnet.public-subnet.id vpc_security_group_ids = [aws_security_group.aws-windows-sg.id]