From 7333d0f98f572e03cd8960030443487efb1dbec9 Mon Sep 17 00:00:00 2001 From: John De Armas Date: Thu, 14 Dec 2023 10:09:48 -0700 Subject: [PATCH] Update ec2.tf to use latest Linux AMI --- scenarios/glue_privesc/terraform/ec2.tf | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scenarios/glue_privesc/terraform/ec2.tf b/scenarios/glue_privesc/terraform/ec2.tf index 2910a07f..7da5e6ff 100644 --- a/scenarios/glue_privesc/terraform/ec2.tf +++ b/scenarios/glue_privesc/terraform/ec2.tf @@ -3,8 +3,25 @@ resource "aws_key_pair" "bob-ec2-key-pair" { public_key = file(var.ssh-public-key-for-ec2) } +data "aws_ami" "latest_amazon_linux" { + most_recent = true + + filter { + name = "name" + values = ["amzn2-ami-hvm-*-x86_64-gp2"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + owners = ["amazon"] +} + + resource "aws_instance" "cg-linux-ec2" { - ami = "ami-05c13eab67c5d8861" + ami = data.aws_ami.latest_amazon_linux.id instance_type = "t2.micro" iam_instance_profile = aws_iam_instance_profile.cg-ec2-instance-profile.name subnet_id = aws_subnet.cg-public-subnet-1.id