From 5ae1a3d752308f8bd48323d1cdd1de7e6e94650d Mon Sep 17 00:00:00 2001 From: mharb Date: Mon, 23 Oct 2023 15:11:46 -0400 Subject: [PATCH] Utilize list comprehension to output EC2 ARNs. --- terraform/data.tf | 5 ++++- terraform/main.tf | 1 + terraform/outputs.tf | 15 ++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/terraform/data.tf b/terraform/data.tf index 3049a18..e0f8315 100644 --- a/terraform/data.tf +++ b/terraform/data.tf @@ -5,7 +5,7 @@ # filter { # name = "name" -# values = var.compute_ami +# values = ["amazon linux"] # } # filter { @@ -18,3 +18,6 @@ # values = ["x86_64"] # } # } + +# data "" "ec2_arns" { +# } \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index e601cb2..35a4a35 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,4 +1,5 @@ terraform { + required_version = ">= 0.13.1" required_providers { aws = { source = "hashicorp/aws" diff --git a/terraform/outputs.tf b/terraform/outputs.tf index da5ffa8..3978617 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -1,9 +1,10 @@ -output "compute_ami" { - description = "Prints the image AMI installed on our EC2s." - value = data.aws_ami.compute_ami -} +# output "compute_ami" { +# description = "Prints the image AMI installed on our EC2s." +# value = data.aws_ami.compute_ami +# } +# Extract EC2 ARN from each instance, into a new map. output "public_ec2" { - description = "Prints the ARN for the publicly accessible EC2" - value = module.standalone_ec2.arn -} + description = "Prints the ARN for the publicly accessible EC2(s)" + value = [for idx, val in module.standalone_ec2 : val.arn] +} \ No newline at end of file