正如您在下面的配置中看到的那样,我正在启动一个现场实例,然后尝试从现场获取 IP 地址。它似乎适用于常规的 ec2 实例(即,这不是现场实例)。
我得到的错误是:
aws_route53_record.staging:资源“aws_spot_instance_request.app-ec2”没有变量“aws_spot_instance_request.app-ec2.public_ip”的属性“public_ip”</p>
这是我正在使用的配置:
resource "aws_spot_instance_request" "app-ec2" {
ami = "ami-1c999999"
spot_price = "0.008"
instance_type = "t2.small"
tags {
Name = "${var.app_name}"
}
key_name = "mykeypair"
associate_public_ip_address = true
vpc_security_group_ids = ["sg-99999999"]
subnet_id = "subnet-99999999"
iam_instance_profile = "myInstanceRole"
user_data = <<-EOF
#!/bin/bash
echo ECS_CLUSTER=APP-STAGING >> /etc/ecs/ecs.config
EOF
}
resource "aws_route53_record" "staging" {
zone_id = "XXXXXXXX"
name = "staging.myapp.com"
type = "A"
ttl = "300"
records = ["${aws_spot_instance_request.app-ec2.public_ip}"]
任何帮助将不胜感激!