Error: Invalid expression
│
│ on main.tf line 22, in resource “aws_instance” “app_server”:
│ 22: + Name = var.instance_name
│
│ Expected the start of an expression, but found an invalid expression token.
It’s hard to tell without the full resource definition, but it seems like you’re trying to set the instance name. This is done via setting the tag Name
:
resource "aws_instance" "web" {
.
.
tags = {
Name = var.instance_name
}
}
I think that +
symbol before Name
is probably what this error is reporting, since a plus sign is not valid in that position.
If you copied the terraform plan
description of some changes into your configuration then note that terraform plan
is only configuration-language-like for ease of human reading and is not intended to be copied verbatim into a .tf
file to run. At the very least you’ll need to remove the +
, -
, ~
and other such markers that Terraform uses to describe what’ll be changed by a particular action.