hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.17k forks source link

Get Private IP of instance launched by autoscaling group #511

Open hashibot opened 7 years ago

hashibot commented 7 years ago

This issue was originally opened by @coolgooze as hashicorp/terraform#11713. It was migrated here as part of the provider split. The original body of the issue is below.


ASG resource "aws_autoscaling_group" "REDIS_ASG" { name = "${var.environment}-REDIS_ASG" launch_configuration = "${aws_launch_configuration.redis_launch_conf.name}"

availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]

vpc_zone_identifier = ["${data.aws_subnet.PrivateDBSubnetAZ1.id}","${data.aws_subnet.PrivateDBSubnetAZ2.id}","${data.aws_subnet.PrivateDBSubnetAZ3.id}"]
min_size = 1
max_size = 1
desired_capacity = 1
health_check_grace_period = 600
health_check_type = "EC2"   
force_delete = "false"
termination_policies = ["OldestInstance"]
tag {
key                 = "Name"
value               = "${var.environment}-int-redis"
propagate_at_launch = true
 }

}

i am trying to create a A Record resource "aws_route53_record" "redis" { zone_id = "${data.aws_route53_zone.dns.zone_id}" name = "redis-${var.environment}.${data.aws_route53_zone.dns.name}" type = "A" ttl = "60" records = ["${aws_autoscaling_group.REDIS_ASG.private_ip}"] }

Output-

Xtigyro commented 2 years ago

5 yrs later - and still unresolved?

jasonkuehl commented 2 years ago

A big no.

BarbaraStanley commented 1 year ago

Deep sigh, needed this. data "aws_instances" "test" { instance_tags = { Role = "HardWorker" }

filter { name = "instance.group-id" values = ["sg-12345678"] }

instance_state_names = ["running", "stopped"] } Is there a way to use the filter to narrow things down, I gave the instances a prefix from the launch template