0
votes

I am creating an aws autoscaling group in terraform as below:

resource "aws_autoscaling_group" "my_cluster" { name = "${var.name}-my-cluster"

max_size = 10 min_size = 5 .... }

How to expose the instance information created as part of this auto-scaling group in output section?

1

1 Answers

1
votes

When using AWS autoscaling with Terraform, Terraform manages only the autoscaling group itself. The individual instances are managed by AWS autoscaling directly, and they may be destroyed and created when Terraform isn't running in response to failures or scaling triggers.

For that reason, Terraform is not aware of the individual instances created. If you need to access those instances in some other system then that system should directly call AWS APIs to obtain that information, rather than obtaining it from Terraform, in order to ensure it always sees the latest selection of instances, rather than just the ones that happened to exist when was Terraform last run.