问题描述
我有一个模块,该模块创建子模块,每个子模块都有一个custom_error_response,它们会降落到不同的response_page_path。
在主模块中我添加了;
custom_error_response = [
{
error_code = "403"
error_caching_min_ttl = "30"
response_code = "200"
response_page_path = "/${var.default_root_object}"
},]
,变量default_root_object是:
variable "default_root_object" {
description = "Default root object at origin for CloudFront distribution"
}
在子模块中,我在variable.tf中添加了以下内容:
variable "custom_error_response" {
description = "(Optional) - List of one or more custom error response element maps"
type = "list"
default = []
}
在每个子模块的main.tf中,我还定义了custom_error_response,如下所示:
dynamic "custom_error_response" {
for_each = var.custom_error_response
content {
error_caching_min_ttl = lookup(custom_error_response.value,"error_caching_min_ttl",null)
error_code = custom_error_response.value.error_code
response_code = lookup(custom_error_response.value,"response_code",null)
response_page_path = lookup(custom_error_response.value,"response_page_path",null)
}
}
当我运行terraform初始化时可以,但是当我运行terraform计划时,对于我制作的8个子模块,它会给我8次相同的错误。
Error: Invalid value for module argument
on portal_distribution/main.tf line 32,in module "**mainmodule**":
32: custom_error_response = [
33: {
34: error_code = "403"
35: error_caching_min_ttl = "30"
36: response_code = "200"
37: response_page_path = "/${var.default_root_object}"
38: },39: ]
The given value is not suitable for child module variable
"custom_error_response" defined at
.terraform/modules/**submodule**_portal.**mainmodule**/modules/aws-terraform-cloudfront_s3_origin/variables.tf:302,1-33:
element 0: string required.
如何解决该错误?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)