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]