Skip to content

Commit e6d3561

Browse files
authored
Only get data.aws_ami.info if it's actually required (#151)
1 parent 916c3af commit e6d3561

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ locals {
1414
availability_zone = var.availability_zone != "" ? var.availability_zone : data.aws_subnet.default.availability_zone
1515
ami = var.ami != "" ? var.ami : join("", data.aws_ami.default.*.image_id)
1616
ami_owner = var.ami != "" ? var.ami_owner : join("", data.aws_ami.default.*.owner_id)
17-
root_volume_type = var.root_volume_type != "" ? var.root_volume_type : data.aws_ami.info.root_device_type
17+
root_volume_type = var.root_volume_type != "" ? var.root_volume_type : one(data.aws_ami.info[*].root_device_type)
1818

1919
region_domain = local.region == "us-east-1" ? "compute-1.amazonaws.com" : "${local.region}.compute.amazonaws.com"
2020
eip_public_dns = "ec2-${replace(join("", aws_eip.default.*.public_ip), ".", "-")}.${local.region_domain}"
@@ -71,6 +71,8 @@ data "aws_ami" "default" {
7171
}
7272

7373
data "aws_ami" "info" {
74+
count = var.root_volume_type != "" ? 0 : 1
75+
7476
filter {
7577
name = "image-id"
7678
values = [local.ami]

0 commit comments

Comments
 (0)