将变量传递给terraform动态块v12 [英] passing variable to terraform dynamic block v12
本文介绍了将变量传递给terraform动态块v12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用此仓库中的代码 https://github.com/jmgreg31/terraform-aws-cloudfront/
I am trying to use the code in this repo https://github.com/jmgreg31/terraform-aws-cloudfront/
但是在设置变量时会遇到困难.
but getting a hard time in setting the variables.
我的variables.tf具有此值,但不知何故:
My variables.tf has this value, but somehow its not working :
variable "dynamic_s3_origin_config" {
default =
[
{
domain_name = "domain.s3.amazonaws.com"
origin_id = "S3-domain-cert"
origin_access_identity = "origin-access-identity/cloudfront/1234"
},
{
domain_name = "domain2.s3.amazonaws.com"
origin_id = "S3-domain2-cert"
origin_access_identity = "origin-access-identity/cloudfront/1234"
origin_path = ""
}
]
}
模块中的变量定义如下:
variable definition in module looks like:
variable dynamic_s3_origin_config {
description = "Configuration for the s3 origin config to be used in dynamic block"
type = list(map(string))
default = []
}
有人可以帮助我了解我在这里做错了什么吗?
can someone help me to understand what I am doing wrong here?
terraform plan
Error: Invalid expression
on variables.tf line 65, in variable "dynamic_s3_origin_config":
65:
66:
Expected the start of an expression, but found an invalid expression token.
推荐答案
在default =
和表达式的开头之间不能有换行符.尝试将块更改为:
You can't have a newline between default =
and the start of the expression. Try changing your block to:
variable "dynamic_s3_origin_config" {
default = [
{
domain_name = "domain.s3.amazonaws.com"
origin_id = "S3-domain-cert"
origin_access_identity = "origin-access-identity/cloudfront/1234"
},
{
domain_name = "domain2.s3.amazonaws.com"
origin_id = "S3-domain2-cert"
origin_access_identity = "origin-access-identity/cloudfront/1234"
origin_path = ""
}
]
}
这篇关于将变量传递给terraform动态块v12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文