我正在尝试导入 helm 图表并使用 terraform
helm_release
资源进行管理。
这就是我正在努力做的事情
import {
id = "ingress-nginx/ingress-nginx"
to = helm_release.ingress_nginx
}
module "import_manual_created_resources" {
source = "../modules/import_manual_created_resources"
env = var.environment_prefix
ingress_nginx_ns = "ingress-nginx"
ingress_nginx_release_name = "ingress-nginx"
}
模块的main.tf
resource "helm_release" "ingress_nginx" {
name = var.ingress_nginx_release_name
chart = var.ingress_nginx_release_name
namespace = var.ingress_nginx_ns
create_namespace = false
values = [
"${file("./helm_charts_values/${var.ingress_nginx_release_name}/env/${var.env}.yaml")}"
]
}
没有错误,但 Terraform HCP 说
Cannot apply automatically generated configuration
This plan generated resource configuration and cannot be applied. Please review the generated code and include it in your configuration before moving forward.
我通过删除模块并使用直接资源修复了它。
模块不支持导入
import {
id = "${local.manually_created_resources.ingress_nginx.namespace}/${local.manually_created_resources.ingress_nginx.release_name}"
to = helm_release.ingress_nginx
}
resource "helm_release" "ingress_nginx" {
name = local.manually_created_resources.ingress_nginx.release_name
repository = local.manually_created_resources.ingress_nginx.repository
chart = local.manually_created_resources.ingress_nginx.chart_name
namespace = local.manually_created_resources.ingress_nginx.namespace
create_namespace = false
values = [
"${file("./helm_charts_values/ingress-nginx/env/${var.environment_prefix}.yaml")}"
]
}