At the beginning I want to build just one windows machine, so this code works fine at the beginning:
output "Administrator_Password" {
value = "${rsadecrypt(aws_instance.new_instance.password_data, file("${module.ssh_key_pair.private_key_filename}"))}"
}
But once I introduce count
to resource "aws_instance" "new_instance" {
, I have to add *
to the expression aws_instance.new_instance.*.password_data
.
But then I start to get this error:
Error: Error running plan: 1 error(s) occurred:
* output.Administrator_Password: At column 3, line 1: rsadecrypt: argument 1 should be type string, got type list in:
${rsadecrypt(aws_instance.new_instance.*.password_data, file("${module.ssh_key_pair.private_key_filename}"))}
I have tried the count.index
syntax but they do not work. The variants are
aws_instance.new_instance.password_data[count.index]
and
aws_instance.new_instance.password_data[aws_instance.new_instance.count.index]