Skip to content

redeux/terraform-kubernetes-kubeconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-kubernetes-kubeconfig

Generate kubeconfig files with Terraform

Example

module "kubeconfig" {
  source  = "redeux/kubeconfig/kubernetes"
  version = "0.0.2"

  current_context = "kind-kind"
  clusters = [{
    "name" : "kind-kind",
    "server" : "https://127.0.0.1:53851",
    certificate_authority_data = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeE1EUXlNVEExTURVeU4xb1hEVE14TURReE9UQTFNRFV5TjFvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTnE1ClE0N205dHpTQzhjVnpxYUVUN24zOGdPQi9MMkdtb0VUbFllRG1KazBUWTFWQnZ3QjA4OTc2NnovcHhqMGs3bVMKTTlacmhMYkhNcUVaWTllZ3NNcDVxbHNkV0xMbFkvNFY4a1l6TWp6Vjd4NXdtM0tSa3h6NUJRaXJIWHFyeS93WApwNlpha3dCQTZycXNJSW5Kd29WYVQwNXFQVHhxQmpEN09RL1V1VFNwUVBpVmZOYjZKL2lRZWQ4eG9LaGpKU05WCkc3SGNCQjZodVdoOHNVSFdnUGZydGp4Y1ZlUDlwSytDMEJ0SDBEL0V4cjc4RmdLTzRhL2RSVk5lN1JiTlQ0aG0KM0pxSG9TMXZpdkJsSUdpQTYyalNqVFVIRmxCUXowbmxlR1VBTEllcEIyNXlJR3l6ZnVxY2YyRlZyVUYxRStZaQpDZTh5NVhoY1I2RkV0bHhWZnJFQ0F3RUFBYU1qTUNFd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFHUHFiRjU0Zk5kNmo1ZTMyZThjZGV3U2hZa0wKQzJiWVVicTFaNk9ic05iM3pHOTRucUYyaFArdWdobHBudFRqaWkwV04zbW5zOFY3cUlkOE1RQm0wRDVVNi94SAp4K3EzcW5TWm95VUd6R3I5UjloempKN3ovWCt4TUYxT0xsTEZnTTljZGhTdFhyajJNWSthTTdzMjFBQy8wU2NVCmtabjcvdzN6MnRCTExFVlNpQ1dXeDc0eEl5bExQTUovaFhRRHNuYUtmTEhSeXVtalNXVTdPZ1I1Q1FLeXJEQXMKenJjU0Z0Z0dPYmJoellDVDlWK1dIU0Q0dGZONFQwbFdhU3dDTXNOUmkzQ3lOV1EzZy9GSWNmOGszWGt0VXdjLwpiVnAxV2VJak04VjBibWN6V2pLNmkvR0dqZUVKRW5oZkkzdi9WZGxKc3ljR3YwODVpMTNuRFF6dTgvbz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo="
  }]
  contexts = [{
    "name" : "kind-kind",
    "cluster_name" : "kind-kind"
    "user" : "kind-kind"
  }]
  users = [{
    "name" : "",
    "client_certificate_data" : "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJWjFvaWJPR3dwakF3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TVRBME1qRXdNalF3TWpKYUZ3MHlNakEwTWpFd01qUXdNalJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXdsMENqQTlsUnNqWDV1ckoKeHNMUm4ybFRlL3Z0VFRuN0dCN0x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Bxa2J4K3hKL3FENWhLdWl6OFJ1aDZhUEYyZjVudFFNRXh1bjQ3OTJ5WDBVMwoxMy96a3BDekJ3Nm9uYXNTdUFWbm9XNk4yakpjb2QzRnpLeE1VQjk4RUJyOUNBWTdmeWxDMUh4RmNGaGlnanJVCk4wVVVYdUJBdkxvT2FrWnduVEVOTHBzQ2dZQmxqVHB3cGdSRDVzMXhBc1hUbEN1RTNLZjNKcXdLQ3UxU21LRDkKUDFyQlI0cVZEa002VjJONkxvc0pSVHcyTUZ4RVVRSWpzdDhQUFM0SXRkcDZxVzZFTXF0Ti9uYUFLKzYyWFBacApOYk5ndi9SMFNUVnJVR00wNExpUW1ZaEY4NWdWQnErUXhSZHdLaHJvS3ViNFVPWmVWN0lsT3hpVEQ0TkEzNDc5Clo0Rm54d0tCZ1FEdUx6WXd0SkYvckc2dEV4THZ3U3ZLMWQ0UVI2TDZVaHh2NHRnU2k1anlLQytUeUtiakNPSUEKdEZJTk1HbWY2em5BaDlwQVBLd0VKSDlPVDY5bUR3bjh6TnlrZUxZQmZNYlRrcEdqSkRuSEdjaWVkUjJBbXRqdgpBQVNXQVhNY2FWUkpFVXhVLzFrWjBUUnZsR1J3K0psdDhodDZvdWZ2dGZueDlpc01sUmxrN0E9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
  }]
}

Requirements

Name Version
terraform >=0.15.0
local >=2.0.0

Providers

Name Version
local >=2.0.0

Modules

No modules.

Resources

Name Type
local_file.kubeconfig resource

Inputs

Name Description Type Default Required
clusters List of cluster configurations
set(object({
name = optional(string)
server = optional(string)
certificate_authority = optional(string)
certificate_authority_data = optional(string)
insecure_skip_tls_verify = optional(bool)
}))
n/a yes
colors Colors bool true no
contexts List of context configurations
set(object({
name = optional(string)
cluster_name = optional(string)
namespace = optional(string)
user = optional(string)
}))
n/a yes
current_context Context name string "" no
filename Filename string "kubeconfig" no
users List of user configurations
set(object({
name = optional(string)
username = optional(string)
password = optional(string)
token = optional(string)
client_certificate = optional(string)
client_key = optional(string)
client_certificate_data = optional(string)
client_key_data = optional(string)
}))
n/a yes

Outputs

Name Description
kubeconfig_content HCL representation of kubeconfig file contents
kubeconfig_path Path to the kubeconfig file