sighupio / fury-distribution

Kubernetes Fury Distribution (Core Modules) - A battle-tested open-source Kubernetes distribution
https://kubernetesfury.com/
BSD 3-Clause "New" or "Revised" License
162 stars 13 forks source link

Eks kubernetes terraform template #219

Open Al-Pragliola opened 5 months ago

Al-Pragliola commented 5 months ago

check for nils in

.spec.kubernetes.awsAuth.additionalAccounts .spec.kubernetes.awsAuth.users .spec.kubernetes.awsAuth.roles

to avoid template: main.auto.tfvars.tpl:56:24: executing "main.auto.tfvars.tpl" at <.spec.kubernetes.awsAuth.additionalAccounts>: map has no entry for key "additionalAccounts"

{{- if hasKeyAny .spec.kubernetes "awsAuth" }}
    {{- if gt (len .spec.kubernetes.awsAuth.additionalAccounts) 0 }}
eks_map_accounts = {{ toJson .spec.kubernetes.awsAuth.additionalAccounts }}
    {{- end }}

    {{- if gt (len .spec.kubernetes.awsAuth.users) 0 }}
        {{- $users := list }}

        {{- range $u := .spec.kubernetes.awsAuth.users }}
            {{- $currUser := dict "username" $u.username "userarn" $u.userarn "groups" $u.groups }}
            {{- $users = append $users $currUser }}
        {{- end }}
eks_map_users = {{ toPrettyJson $users | join ","}}
    {{- end }}

    {{- if gt (len .spec.kubernetes.awsAuth.roles) 0 }}
        {{- $roles := list }}

        {{- range $r := .spec.kubernetes.awsAuth.roles }}
            {{- $currRole := dict "username" $r.username "rolearn" $r.rolearn "groups" $r.groups }}
            {{- $roles = append $roles $currRole }}
        {{- end }}
eks_map_roles = {{ toPrettyJson $roles | join "," }}
    {{- end }}
{{- end }}