Access autoscaling_groups name attribute on aws_eks_node_group resource

Attribute seems to be nested in a list of lists, but I can’t get to the actual name value of the autoscaling_group. Tested in Output and I can get to the resources atttribute, but can’t seem to drill down any further without errors. This attribute seems to be structured differently than those on most resources I’ve worked with previously.

This output reference:

output "eks-ng-asg" {
  value       = "${aws_eks_node_group.cluster_node_group.0.resources[0]}"
  description = "EKS Node Group AutoScaling Groups"
}

Returns this response:

eks-ng-asg = {
  autoscaling_groups = [map[name:eks-aaaa12-1234-123a-0c13-26c51d00eabe]]
  remote_access_security_group_id =
}

I want to return just the ASG name value:
“eks-aaaa12-1234-123a-0c13-26c51d00eabe”

After a battle I found the following works for me:

output “eks_node_asg_name” {
value = aws_eks_node_group.eks_node_group.resources[0].autoscaling_groups[0].name
}

Although in IntelliJ the “name” part remains as a unresolved reference name.

1 Like