简体   繁体   English

属性“tags”的值不合适:元素“lm:FunctionalArea”:需要字符串

[英]Inappropriate value for attribute "tags": elemen "lm:FunctionalArea": string required

I'm running into this error:我遇到了这个错误:


Inappropriate value for attribute "tags": element "lm:FunctionalArea": string required.

I'm building a module in gitlab that is being imported into an instance of Terraform Enterprise.我正在 gitlab 中构建一个模块,该模块正在导入到 Terraform Enterprise 的实例中。 Basically, we are going to pull in a common list of tags that can be imported onto any resource just by using the module.基本上,我们将引入一个通用的标签列表,只需使用该模块即可将这些标签导入到任何资源中。

Here is the series of scripts that make up the module:以下是构成该模块的一系列脚本:

main.tf主程序


locals {

 

  // lm_BusinessArea         = ["EO"]

  // lm_FunctionalArea       = ["TechOffice"]

  // automatic_daily_startup = ["disabled"]

  // automatic_daily_shutdown = ["enabled"]

  // Name = ["Terraform Enterprise EC2 Instance"]

 

  lm_BusinessArea         = "EO"

  lm_FunctionalArea       = "TechOffice"

  automatic_daily_startup = "disabled"

  automatic_daily_shutdown = "enabled"

  Name = "Terraform Enterprise EC2 Instance"

 

  default_tags_map = {

     "lmBusinessArea"       = local.lm_BusinessArea

     "lm:FunctionalArea"       = local.lm_FunctionalArea

     "automatic_daily_startup"       = local.automatic_daily_startup

     "automatic_daily_shutdown" = local.automatic_daily_shutdown

     "Name" = local.Name

  }

 

}

 

outputs.tf输出.tf


output "default_tags" {

  description = "Map containing the default ITREx Tag list"

  value       = local.default_tags_map

}

 

Now this is an example of the module being called in another terraform build现在这是在另一个 terraform 构建中调用模块的示例

(some information was replaced with x's due to its sensitivity) (部分信息因敏感被替换为x)


module "itrex-common-tags" {

  source  = "terraform.us.lmco.com/eo-itrex/itrex-common-tags/aws"

  version = "1.0.0"

}

 

resource "aws_instance" "itrex_test_instance" {

  ami             = "ami-xxxxxxxxxxxxxx"

  instance_type   = "t3.medium"

  security_groups  = ["sg-xxxxxxxxxxxxx"]

  subnet_id       = "subnet-xxxxxxxxxxxx"

  key_name        = "itrex-key"

 

  tags = module.itrex-common-tags.default_tags

}

 

Now the problem is that it doesn't recognize the values in my main.tf script as strings even with the brackets removed.现在的问题是,即使删除了括号,它也无法将我的 main.tf 脚本中的值识别为字符串。 This is the error I receive in my terraform enterprise UI.这是我在 terraform 企业用户界面中收到的错误。


Error: Incorrect attribute value type

on main.tf line 13, in resource "aws_instance" "itrex_test_instance":

  tags = module.itrex-common-tags.default_tags

Inappropriate value for attribute "tags": element "lm:FunctionalArea": string required.

I'm stumped fellas, I KNOW i'm defining these values as strings however, when they are being referenced something gets lost in translation.伙计们,我很难过,我知道我将这些值定义为字符串,但是,当它们被引用时,某些东西会在翻译中丢失。

This questions was similar to this too, but the answer just didn't help me at all.这个问题也与类似,但答案根本没有帮助我。

This is as thorough as I can be in stating this problem.这是我在陈述这个问题时所能做到的最彻底。 This is my real code and nothing else an be added to this question to make it more clear.这是我的真实代码,没有任何其他内容可以添加到这个问题中以使其更清楚。 Terraform is not recognizing my local values as strings whether they are in brackets or not, and I believe there is something being lost in translation when the instance resource tries to call the tagging module. Terraform 无法将我的本地值识别为字符串,无论它们是否在括号中,我相信当实例资源尝试调用标记模块时,翻译过程中会丢失一些东西。

I see you have commented out this code我看到你已经注释掉这段代码

// lm_BusinessArea         = ["EO"]
// lm_FunctionalArea       = ["TechOffice"]
// automatic_daily_startup = ["disabled"]
// automatic_daily_shutdown = ["enabled"]
// Name = ["Terraform Enterprise EC2 Instance"]

This is the syntax you should be using instead of bracketless strings.这是您应该使用的语法,而不是无括号的字符串。 Also you have your tag values in quotations and they should be like this without the quotations你也有引号中的标签值,它们应该像这样没有引号

lmBusinessArea       = local.lm_BusinessArea

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM