terraform-provider-helm: Error: stat /Users/xxxxx/.kube/config: no such file or directory when trying to use with EKS
Terraform Version
12.18
Affected Resource(s)
- helm_release
Terraform Configuration Files
data "aws_eks_cluster_auth" "cluster-auth" {
depends_on = [aws_eks_cluster.default]
name = "aws_eks_cluster.default"
}
provider "helm" {
alias = "eks"
kubernetes {
# config_path = "${path.module}/.kube/config"
host = aws_eks_cluster.default.endpoint
cluster_ca_certificate = aws_eks_cluster.default.certificate_authority[0].data #base64decode(aws_eks_cluster.default.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster-auth.token
load_config_file = false
}
}
resource "helm_release" "controllers" {
name = "controllers"
atomic = true
chart = "./controllers"
depends_on = [
aws_eks_cluster.default,
local_file.kubeconfig,
aws_autoscaling_group.default
]
set {
name = "clusterName"
value = aws_eks_cluster.default.id
}
set {
name = "region"
value = var.aws_region
}
set {
name = "zone"
value = var.route53zone
Expected Behavior
It creates a Helm release with my the YAML in my controllers folder.
Actual Behavior
Receive this errors instead:
_Error: stat /Users/xxxxx/.kube/config: no such file or directory
on main.tf line 610, in resource “helm_release” “controllers”: 610: resource “helm_release” “controllers” {_
Here’s what I know; if I have a ~/.kube/config file present, everything works just fine. Thus, when running terraform apply locally on my laptop, it works. However, I’m trying to replicate running terraform apply in a fresh container in our CD platform, which won’t have that file.
Now, oddly enough, even though the rest of my EKS TF module has commands all over the place using “${path.module}/.kube/config” as the source for the kubeconfig and work just fine, Helm3 provider does not. It INSISTS I have a config file at ~/.kube/config, even though I:
- Have a perfectly useable one at ${path.module}/.kube/config, path.module being the root of my module repo. This is useable with literally everything else, including various kubectl commands.
- Tried, as you can see above, not even using a file and just configuring the provider with the cert, token, etc., as well as specifying load_config_file to false. The provider seems to not care about any of this, everything be damned if there is no ~/.kube.config.
Steps to Reproduce
terraform apply against an EKS cluster.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
I use another way: Output from my eks modules:
here is my main modules call:
Get it in my next modules with: