-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enable management of the aws-auth ConfigMap as a module
- Loading branch information
1 parent
b84bf90
commit 392ecfd
Showing
8 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
data "template_file" "map_instances" { | ||
count = var.create_eks ? length(var.map_instances) : 0 | ||
template = file("${path.module}/templates/worker-role.tpl") | ||
|
||
vars = var.map_instances[count.index] | ||
} | ||
|
||
resource "kubernetes_config_map" "aws_auth" { | ||
count = var.create_eks && var.manage_aws_auth ? 1 : 0 | ||
|
||
metadata { | ||
name = "aws-auth" | ||
namespace = "kube-system" | ||
} | ||
|
||
data = { | ||
mapRoles = <<EOF | ||
${join("", distinct(data.template_file.map_instances.*.rendered))} | ||
%{if length(var.map_roles) != 0}${yamlencode(var.map_roles)}%{endif} | ||
EOF | ||
mapUsers = yamlencode(var.map_users) | ||
mapAccounts = yamlencode(var.map_accounts) | ||
} | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "config_map_aws_auth" { | ||
description = "A kubernetes configuration to authenticate to this EKS cluster." | ||
value = kubernetes_config_map.aws_auth.* | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- rolearn: ${instance_role_arn} | ||
username: system:node:{{EC2PrivateDNSName}} | ||
groups: | ||
- system:bootstrappers | ||
- system:nodes | ||
%{~ if platform == "windows" ~} | ||
- eks:kube-proxy-windows | ||
%{~ endif ~} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
variable "create_eks" { | ||
description = "Controls if EKS resources should be created (it affects almost all resources)." | ||
type = bool | ||
default = true | ||
} | ||
|
||
variable "manage_aws_auth" { | ||
description = "Whether to apply the aws-auth configmap file." | ||
default = true | ||
} | ||
|
||
variable "map_accounts" { | ||
description = "Additional AWS account numbers to add to the aws-auth configmap. See examples/basic/variables.tf for example format." | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "map_instances" { | ||
description = "IAM instance roles to add to the aws-auth configmap. See examples/basic/variables.tf for example format." | ||
type = list(object({ | ||
instance_role_arn = string | ||
platform = string | ||
})) | ||
default = [] | ||
} | ||
|
||
variable "map_roles" { | ||
description = "Additional IAM roles to add to the aws-auth configmap. See examples/basic/variables.tf for example format." | ||
type = list(object({ | ||
rolearn = string | ||
username = string | ||
groups = list(string) | ||
})) | ||
default = [] | ||
} | ||
|
||
variable "map_users" { | ||
description = "Additional IAM users to add to the aws-auth configmap. See examples/basic/variables.tf for example format." | ||
type = list(object({ | ||
userarn = string | ||
username = string | ||
groups = list(string) | ||
})) | ||
default = [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters