diff --git a/main.tf b/main.tf index 19b01c3..576a1fe 100644 --- a/main.tf +++ b/main.tf @@ -15,6 +15,11 @@ */ locals { + eni_configs = [for e in var.pods_subnets : { + name = e.availability_zone + subnet = e.id + securityGroups = [aws_eks_cluster.quortex.vpc_config[0].cluster_security_group_id] + }] # The Quortex cluster OIDC issuer. cluster_oidc_issuer = trimprefix(aws_eks_cluster.quortex.identity[0].oidc[0].issuer, "https://") node_group_labels = [ @@ -185,13 +190,6 @@ locals { } } -# delays creation of add-ons after aws_eks_cluster -resource "time_sleep" "wait_3_minutes" { - depends_on = [aws_eks_cluster.quortex] - - create_duration = "3m" -} - # Eks addons resource "aws_eks_addon" "quortex_addon" { for_each = { for k, v in var.cluster_addons : k => v } @@ -271,3 +269,18 @@ resource "aws_cloudwatch_log_group" "cluster_logs" { retention_in_days = var.cluster_logs_retention tags = var.tags } + +resource "helm_release" "eni_configs" { + count = var.handle_eni_configs ? 1 : 0 + version = "1.0.0" + chart = "empty" + repository = "https://quortex.github.io/helm-charts" + name = "aws-vpc-cni-config" + + values = [ + templatefile("${path.module}/templates/eniconfigs.yaml", { + eniConfigs : jsonencode(local.eni_configs) + }) + ] + depends_on = [aws_eks_addon.quortex_addon] +} diff --git a/templates/eniconfigs.yaml b/templates/eniconfigs.yaml new file mode 100644 index 0000000..ff4c433 --- /dev/null +++ b/templates/eniconfigs.yaml @@ -0,0 +1,16 @@ +manifests: |- + {{- range .Values.eniConfigs }} + apiVersion: crd.k8s.amazonaws.com/v1alpha1 + kind: ENIConfig + metadata: + name: {{ .name }} + spec: + subnet: {{ .subnet }} + {{- with .securityGroups }} + securityGroups: + {{- toYaml . | nindent 4 }} + {{- end }} + --- + {{- end }} + +eniConfigs: ${eniConfigs} diff --git a/variables.tf b/variables.tf index 6a1ad75..f3ce924 100644 --- a/variables.tf +++ b/variables.tf @@ -167,6 +167,21 @@ variable "master_authorized_networks" { default = {} } +variable "pods_subnets" { + type = map(object({ id = string, availability_zone = string, cidr = string, public = bool })) + description = <