I’m spinning up a spot instance as you can see in below config and then trying to get the IP address from the spot. It seems to work fine with a regular ec2 instance (ie. that is not spot instance).
The error that I get is:
aws_route53_record.staging: Resource‘aws_spot_instance_request.app-ec2’ does not have attribute‘public_ip’ for variable ‘aws_spot_instance_request.app-ec2.public_ip’
Here is the config that I’m using:
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/bashecho 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}"]
The spot request is fulfilled on the AWS Console as per below:
Any help will be greatly appreciated!