I created a auto scaling group in the Open Telekom Cloud provider:
resource "opentelekomcloud_as_group_v1" "worker" {
scaling_group_name = "worker"
scaling_configuration_id = opentelekomcloud_as_configuration_v1.worker.id
desire_instance_number = 2
min_instance_number = 2
max_instance_number = 2
...
}
Now, I want to create an Ansible inventory to access the servers. The auto scaling group has an attribute instances
, which is a list of strings containing instance IDs.
In order to write out a proper Ansible inventory, I need to access the property access_ip_v4
of those instances.
BUT: Terraform doesn’t know that those instances exist, it just sees a list of strings, there are no corresponding opentelekomcloud_compute_instance_v2
resources.
Is there any way I can achive that in Terraform or must I create an external script? Can I e.g. map the ID strings to resources of the type opentelekomcloud_compute_instance_v2
without actually creating them another time (they are alredy there as part of the ASG)?