Unknown token IDENT aws_region

18,718

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:

  1. Don’t mix the syntaxes in the same Terraform code, if so, downgrade manually your code to 0.11x
  2. Put all your Terraform code syntax in 0.11x
  3. Then run: terraform 0.12upgrade
Share:
18,718
Eoin
Author by

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, 2022

Comments

  • Eoin
    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 state type = 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 on list(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
    Eoin over 4 years
    Welcome to the community, and thanks for your answer.
  • Eoin
    Eoin over 4 years
    Is 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
    Aymen Segni over 4 years
    $ terraform version : Prints the Terraform version