@@ -368,17 +368,8 @@ locals {
368
368
[for group in module . fargate_profile : group . fargate_profile_pod_execution_role_arn ],
369
369
var. aws_auth_fargate_profile_pod_execution_role_arns ,
370
370
))
371
- }
372
-
373
- resource "kubernetes_config_map" "aws_auth" {
374
- count = var. create && var. create_aws_auth_configmap ? 1 : 0
375
-
376
- metadata {
377
- name = " aws-auth"
378
- namespace = " kube-system"
379
- }
380
371
381
- data = {
372
+ aws_auth_configmap_data = {
382
373
mapRoles = yamlencode (concat (
383
374
[for role_arn in local . node_iam_role_arns_non_windows : {
384
375
rolearn = role_arn
@@ -415,6 +406,17 @@ resource "kubernetes_config_map" "aws_auth" {
415
406
mapUsers = yamlencode (var. aws_auth_users )
416
407
mapAccounts = yamlencode (var. aws_auth_accounts )
417
408
}
409
+ }
410
+
411
+ resource "kubernetes_config_map" "aws_auth" {
412
+ count = var. create && var. create_aws_auth_configmap ? 1 : 0
413
+
414
+ metadata {
415
+ name = " aws-auth"
416
+ namespace = " kube-system"
417
+ }
418
+
419
+ data = local. aws_auth_configmap_data
418
420
419
421
lifecycle {
420
422
# We are ignoring the data here since we will manage it with the resource below
@@ -426,52 +428,17 @@ resource "kubernetes_config_map" "aws_auth" {
426
428
resource "kubernetes_config_map_v1_data" "aws_auth" {
427
429
count = var. create && var. manage_aws_auth_configmap ? 1 : 0
428
430
429
- force = false
431
+ force = true
430
432
431
433
metadata {
432
434
name = " aws-auth"
433
435
namespace = " kube-system"
434
436
}
435
437
436
- data = {
437
- mapRoles = yamlencode (concat (
438
- [for role_arn in local . node_iam_role_arns_non_windows : {
439
- rolearn = role_arn
440
- username = " system:node:{{EC2PrivateDNSName}}"
441
- groups = [
442
- " system:bootstrappers" ,
443
- " system:nodes" ,
444
- ]
445
- }
446
- ],
447
- [for role_arn in local . node_iam_role_arns_windows : {
448
- rolearn = role_arn
449
- username = " system:node:{{EC2PrivateDNSName}}"
450
- groups = [
451
- " eks:kube-proxy-windows" ,
452
- " system:bootstrappers" ,
453
- " system:nodes" ,
454
- ]
455
- }
456
- ],
457
- # Fargate profile
458
- [for role_arn in local . fargate_profile_pod_execution_role_arns : {
459
- rolearn = role_arn
460
- username = " system:node:{{SessionName}}"
461
- groups = [
462
- " system:bootstrappers" ,
463
- " system:nodes" ,
464
- " system:node-proxier" ,
465
- ]
466
- }
467
- ],
468
- var. aws_auth_roles
469
- ))
470
- mapUsers = yamlencode (var. aws_auth_users )
471
- mapAccounts = yamlencode (var. aws_auth_accounts )
472
- }
438
+ data = local. aws_auth_configmap_data
473
439
474
440
depends_on = [
441
+ # Required for instances where the configmap does not exist yet to avoid race condition
475
442
kubernetes_config_map . aws_auth ,
476
443
]
477
444
}
0 commit comments