Initial commit.

This commit is contained in:
Patrick MARIE
2022-07-01 14:12:11 +02:00
commit 188cf2679c
58 changed files with 1837 additions and 0 deletions

3
modules/eks-auth/data.tf Normal file
View File

@ -0,0 +1,3 @@
data "aws_eks_cluster_auth" "self" {
name = var.cluster_id
}

14
modules/eks-auth/main.tf Normal file
View File

@ -0,0 +1,14 @@
locals {
current_roles = yamldecode(yamldecode(var.aws_auth_configmap_yaml).data.mapRoles)
}
resource "kubernetes_config_map" "aws_auth" {
metadata {
name = "aws-auth"
namespace = "kube-system"
}
data = {
mapRoles = yamlencode(concat(local.current_roles, var.aws_auth_additional_roles))
}
}

View File

@ -0,0 +1,5 @@
provider "kubernetes" {
host = var.cluster_endpoint
cluster_ca_certificate = base64decode(var.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.self.token
}

View File

@ -0,0 +1,28 @@
variable "aws_auth_configmap_yaml" {
description = "Formatted yaml for base aws-auth configmap containing roles used in cluster node groups/fargate profiles"
type = string
}
variable "aws_auth_additional_roles" {
type = list(object({
rolearn = string
groups = list(string)
username = string
}
))
}
variable "cluster_id" {
type = string
description = "The name/id of the EKS cluster. Will block on cluster creation until the cluster is really ready"
}
variable "cluster_endpoint" {
type = string
description = "Endpoint for your Kubernetes API server"
}
variable "cluster_certificate_authority_data" {
type = string
description = "Base64 encoded certificate data required to communicate with the cluster"
}

View File

@ -0,0 +1,12 @@
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.8.0"
}
aws = {
source = "hashicorp/aws"
version = "~> 4.4.0"
}
}
}