以下是我的模块片段:
inputs.tf
:
variable "namespace" {
type = object({
metadata = object({
name = string
})
})
}
main.tf
:
resource "helm_release" "spark" {
name = "spark"
repository = "https://charts.bitnami.com/bitnami"
chart = "spark"
version = "1.2.21"
namespace = var.namespace.metadata.name
}
正如您所见,我正在尝试访问之前创建的 kubernetes_namespace
。
进入我的环境工作区:
resource "kubernetes_namespace" "this" {
metadata {
name = var.namespace
}
}
module "spark" {
source = "../modules/spark"
namespace = kubernetes_namespace.this
workers = 1
}
当我尝试获取计划时,我收到了这个消息:
➜ development terraform plan | xclip -selection clipboard
Error: Invalid value for module argument
on main.tf line 14, in module "spark":
14: namespace = kubernetes_namespace.this
The given value is not suitable for child module variable "namespace" defined
at ../modules/spark/inputs.tf:1,1-21: attribute "metadata": object required.
有什么想法吗?