title: How to get private ip of EC2 instances spin up by ASG using Terraform
body: <p>I have tried following code in order to obtain ip's from ASG, which has been  created using Terraform? Is this a good practice or a bad one? But i got the correct ouput as i expected.</p>
  
  <pre><code>data "aws_instances" "test" {
  instance_tags {
  Environment = "${var.environment}",
  instance    = "${var.db_instance_name}"
  }
  
  instance_state_names = ["running"]
  
  
  depends_on = ["aws_sqs_queue.ansible", "aws_autoscaling_group.sample"]
  }
  </code></pre>
  
  <p>output.tf</p>
  
  <pre><code>output "privateips" {
    value = "${data.aws_instances.test.private_ips}"
  }
  </code></pre>