Unknown token IDENT aws_region
This error appears when you execute terraform 0.12upgrade
and your code syntax is already in Terraform 0.12x or obviously a mix of syntax versions <= 0.11x and 0.12x. Also the Unknown token IDENT error can happen when your installed version on your local machine (or in the remote CI/CD server) is 0.11x and your code syntax is on 0.12x and you run a terraform command such as terraform init
variable "var1" {
type = "list"
...
}
This a Terraform 0.11x syntax the alternative 12x is type = list(string)
To reproduce your error, I have a Terraform code 0.12x, I executed terraform 0.12upgrade
then the unknown token: IDENT
showed up!
In sum, I thought that your first code iteration is already in the correct syntax so there’s no need to upgrade.
To avoid this kind of errors you can add a new version.tf
file in your code with this content:
terraform {
required_version = ">= 0.12"
}
Upgrading tips:
- Don’t mix the syntaxes in the same Terraform code, if so, downgrade manually your code to 0.11x
- Put all your Terraform code syntax in 0.11x
- Then run: terraform 0.12upgrade
Eoin
I'm just here to try and learn some new skills and give back if I can do. If you want to contact me come through my website www.squareballoon.co.uk.
Updated on July 16, 2022Comments
-
Eoin almost 2 years
I have just run Terraform upgrade. My code was updated but now it shows some errors. The first was:
variable "s3_bucket_name" { type = list(string) default = [ "some_bucket_name", "other_bucket_name", ... ] }
It doesn't like
list(string)
. I went back to square one and redid the entire Getting Started tutorial. It said that I could either explicitly statetype = list
or I could implicitly state it by leaving out type and just using the [square brackets].I saw here: unknown token IDENT list error for IP address variable that I could use
"list"
(quotes) but I can't find any information onlist(string)
.So I commented out my
list(string)
which moved the error along to the next part.provider "aws" { region = var.aws_region }
The tutorial indicates that this is the correct way to create a region tag (there's actually part of the tutorial with that exact code).
Can anyone help me to understand what
Unknown token IDENT
means as it's throughout my code but it's not helping me to understand what I should do to fix it. -
Eoin over 4 yearsWelcome to the community, and thanks for your answer.
-
Eoin over 4 yearsIs there a way to know which version of Terraform I am running? Sorry if that is a silly question, I'm really new to this.
-
Aymen Segni over 4 years
$ terraform version
: Prints the Terraform version