diff --git a/data.tf b/data.tf index 630f449..33c184d 100644 --- a/data.tf +++ b/data.tf @@ -8,7 +8,7 @@ data "aws_ami" "this" { filter { name = "name" - values = ["al2023-ami-2023*-*-x86_64"] + values = ["al2023-ami-2023*-*-${local.instance_arch}"] } filter { diff --git a/locals.tf b/locals.tf new file mode 100644 index 0000000..9033e74 --- /dev/null +++ b/locals.tf @@ -0,0 +1,8 @@ +locals { + instance_arch = contains([ + "t4g", + "m6g", + "c6g", + "r6g" + ], substr(var.instance_type, 0, 3)) ? "arm64" : "x86_64" +} diff --git a/main.tf b/main.tf index 8902362..a2639b8 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,7 @@ resource "aws_security_group" "this" { count = var.manage_security_group ? 1 : 0 vpc_id = var.vpc_id + name = "${var.env}-${var.name}" ingress { protocol = "tcp" diff --git a/variables.tf b/variables.tf index 9aee7f2..a607dc5 100644 --- a/variables.tf +++ b/variables.tf @@ -33,13 +33,13 @@ variable "ec2_key_pair_name" { variable "instance_type" { type = string description = "EC2 instance type for bastion host" - default = "t3.nano" + default = "t4g.nano" } variable "instance_ami" { - type = string + type = string description = "AMI ID override for the bastion host. Keep in mind, this module config is targeting Amazon Linux 2023)" - default = "" + default = "" } variable "security_groups" {