Hi
Is there a way to call a variable when referencing a data source?
Eg:
data "aws_ami" "win2019" {
most_recent = true
owners = ["1234"]
filter {
name = "name"
values = ["win2019-desktop*"]
}
}
data "aws_ami" "win2016" {
most_recent = true
owners = ["1234"]
filter {
name = "name"
values = ["win2016-desktop*"]
}
}
resource "aws_instance" "ec2" {
ami = data.aws_ami."${var.ami_version}".id
.tfvars file:
ami_version = "win2016"
Running this gives:
│ Error: Invalid attribute name
│
│ on server.tf line 3, in resource "aws_instance" "ec2":
│ 3: ami = data.aws_ami."${var.ami_version}".id
│ An attribute name is required after a dot.