From 4658106f67425fa7f889fd22b0111971fece7cb1 Mon Sep 17 00:00:00 2001 From: Nick Burgan <122842472+nb1701@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:06:49 -0700 Subject: [PATCH] Look up AMI to use for dumpdb/restoredb (#341) --- cloud/aws/modules/dbaccess/main.tf | 16 +++++++++++++++- cloud/aws/modules/dbaccess/variables.tf | 5 ----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cloud/aws/modules/dbaccess/main.tf b/cloud/aws/modules/dbaccess/main.tf index 3f5dd064..b6daa74a 100644 --- a/cloud/aws/modules/dbaccess/main.tf +++ b/cloud/aws/modules/dbaccess/main.tf @@ -55,8 +55,22 @@ resource "aws_key_pair" "dbaccess_key_pair" { } } +data "aws_ami" "ubuntu" { + most_recent = true + owners = ["099720109477"] # Canonical official + + filter { + name = "name" + values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } +} resource "aws_instance" "dbaccess_host" { - ami = var.host_ami + ami = data.aws_ami.ubuntu.image_id instance_type = var.host_type key_name = aws_key_pair.dbaccess_key_pair.key_name security_groups = [aws_security_group.dbaccess_security_group.id] diff --git a/cloud/aws/modules/dbaccess/variables.tf b/cloud/aws/modules/dbaccess/variables.tf index 7a347359..5fd412af 100644 --- a/cloud/aws/modules/dbaccess/variables.tf +++ b/cloud/aws/modules/dbaccess/variables.tf @@ -34,11 +34,6 @@ variable "public_subnet" { type = string description = "ID of the public subnet to deploy the dbaccess instance in" } -variable "host_ami" { - type = string - description = "AMI ID to use for the dbaccess instance" - default = "ami-080e1f13689e07408" -} variable "host_type" { type = string description = "Instance type to use for the dbaccess instance"