terraform-获取AWS启动配置的私有IP

时间:2018-11-03 23:55:50

标签: terraform

我有这个:

data "template_file" "init" {
  template = "${file("script.tpl")}"  
}
resource "aws_launch_configuration" "ec21" {
  image_id = "${var.image_id}"
  instance_type = "${var.instance_type}"
  key_name      = "${var.key_name}"
  security_groups = ["${aws_security_group.instance.id}"]

  user_data =   "${data.template_file.init.rendered}"

  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_autoscaling_group" "asg" {
  launch_configuration = "${aws_launch_configuration.pgetcd.id}"


  min_size = "${var.min_instances}"
  max_size = "${var.max_instances}"

  vpc_zone_identifier = ["${aws_subnet.sb0.id}", "${aws_subnet.sb1.id}", "${aws_subnet.sb2.id}"]             

 lifecycle {
    create_before_destroy = true
  }
}

如何获取aws_launch_configuration.ec21的私有IP并使用变量将其发送到另一个launch_configuration的template_file?

我曾尝试使用:

aws_launch_configuration.ec21.ip.private_ip,但这不起作用。

0 个答案:

没有答案