Using Terraform version 0.11.7 the code below I get this error:
* output.aws_runner_private_ip_addresses: Resource 'aws_spot_instance_request.runner' does not have attribute 'private_ip' for variable 'aws_spot_instance_request.runner.*.private_ip'
* output.aws_walker_private_ip_addresses: Resource 'aws_spot_instance_request.walker' does not have attribute 'private_ip' for variable 'aws_spot_instance_request.walker.*.private_ip
The output syntax looks correct according the documentation from Terraform
And terraform spot instance request does have the attribute of private_ip which is stated in Terraform documentation here.
resource "aws_spot_instance_request" "walker" {
count = 2
instance_type = "t2.micro"
ami = "ami-0922553b7b0369273"
spot_price = "1"
}
resource "aws_spot_instance_request" "runner" {
count = 2
instance_type = "t2.micro"
ami = "ami-0922553b7b0369273"
spot_price = "1"
}
output "aws_walker_private_ip_addresses" {
value = ["${aws_spot_instance_request.walker.*.private_ip}"]
}
output "aws_runner_private_ip_addresses" {
value = ["${aws_spot_instance_request.runner.*.private_ip}"]
}
However, if I remove the square brackets from the code, it works and there is no error, but the Terraform document seems to be saying I need to use the square brackets since the value would be a list type of returning list of private_ip addresses for each instance. What am I doing wrong here or misunderstanding?
This works, but seems to contradict the document:
output "aws_walker_private_ip_addresses" {
value = "${aws_spot_instance_request.walker.*.private_ip}"
}
output "aws_runner_private_ip_addresses" {
value = "${aws_spot_instance_request.runner.*.private_ip}"
}