未知令牌 IDENT aws_region [英] Unknown token IDENT aws_region

查看:26
本文介绍了未知令牌 IDENT aws_region的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚运行了 Terraform 升级.我的代码已更新,但现在显示一些错误.第一个是:

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",
    ...
  ]
}

它不喜欢list(string).我回到第一个地方,重新编写了整个入门 教程.它说我可以显式声明 type = list 或者我可以通过省略类型而只使用 [方括号] 来隐式声明它.

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].

我在这里看到:IP 的未知令牌 IDENT 列表错误地址变量,我可以使用"list"(引号),但我找不到关于list(string) 的任何信息.

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).

所以我注释掉了我的 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).

任何人都可以帮助我理解 Unknown token IDENT 的含义,因为它贯穿我的整个代码,但这并不能帮助我理解我应该怎么做来修复它.>

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.

推荐答案

当您执行 terraform 0.12upgrade 并且您的代码语法已经在 Terraform 0.12x 或显然是语法版本的混合时出现此错误<= 0.11x 和 0.12x.此外,当您在本地计算机(或远程 CI/CD 服务器中)上安装的版本为 0.11x 并且您的代码语法为 0.12x 并且您运行 terraform 命令(例如 terraform init)时,也会发生 Unknown token IDENT 错误

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"
  ...
} 

这是一个 Terraform 0.11x 语法替代12x 是 type = list(string)

This a Terraform 0.11x syntax the alternative 12x is type = list(string)

为了重现您的错误,我有一个 Terraform 代码 0.12x,我执行了 terraform 0.12upgrade 然后 unknown token: IDENT 出现了!

To reproduce your error, I have a Terraform code 0.12x, I executed terraform 0.12upgrade then the unknown token: IDENT showed up!

总而言之,我认为您的第一次代码迭代已经采用正确的语法,因此无需升级.为避免此类错误,您可以在代码中添加一个新的 version.tf 文件,内容如下:

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"
}

升级提示:

  1. 不要在相同的 Terraform 代码中混合使用语法,如果是这样,请手动将代码降级到 0.11x
  2. 将所有 Terraform 代码语法放入 0.11x
  3. 然后运行:terraform 0.12upgrade

这篇关于未知令牌 IDENT aws_region的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆