-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate provider configs for kubectl & helm (#1044)
* feat: allow variables to specify values in main.tf * filter out nonexistent variables * loop * feat: generate provider configs for kubectl & helm * remove custom provider * tidy * conditionals * index
- Loading branch information
1 parent
4ca082b
commit d832a3c
Showing
7 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{ define "helm_provider" -}} | ||
provider "helm" { | ||
kubernetes { | ||
host = data.aws_eks_cluster.cluster.endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data) | ||
token = data.aws_eks_cluster_auth.cluster.token | ||
} | ||
} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{ define "kubectl_provider" -}} | ||
provider "kubectl" { | ||
host = data.aws_eks_cluster.cluster.endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data) | ||
token = data.aws_eks_cluster_auth.cluster.token | ||
load_config_file = false | ||
apply_retry_count = 15 | ||
} | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
{{ define "kubernetes_provider" -}} | ||
{{ if .ClusterComponentName -}} | ||
{{ if .Kubernetes.ClusterComponentName -}} | ||
data "aws_eks_cluster" "cluster" { | ||
name = data.terraform_remote_state.{{ .ClusterComponentName }}.outputs.cluster_id | ||
name = data.terraform_remote_state.{{ .Kubernetes.ClusterComponentName }}.outputs.cluster_id | ||
} | ||
|
||
data "aws_eks_cluster_auth" "cluster" { | ||
name = data.terraform_remote_state.{{ .ClusterComponentName }}.outputs.cluster_id | ||
name = data.terraform_remote_state.{{ .Kubernetes.ClusterComponentName }}.outputs.cluster_id | ||
} | ||
|
||
provider "kubernetes" { | ||
host = data.aws_eks_cluster.cluster.endpoint | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data) | ||
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data) | ||
token = data.aws_eks_cluster_auth.cluster.token | ||
} | ||
{{ end }}{{ end }} | ||
{{if .Helm -}}{{if not .Helm.CustomProvider -}} | ||
{{template "helm_provider" .Helm -}} | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{- if .Kubectl -}}{{- if not .Kubectl.CustomProvider -}} | ||
{{template "kubectl_provider" .Kubectl -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
|
||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 29 additions & 1 deletion
30
testdata/v2_full_yaml/terraform/envs/staging/k8s-comp/fogg.tf
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.