Skip to content

Commit bef3c36

Browse files
rottenbytesmax-rocket-internet
authored andcommitted
Allow additional policies to be attached to worker nodes (#308)
Example usage : we want our nodes to be able to update route53 record for using external-dns. ```hcl data "template_file" "eks_worker_additional_route53_policy" { template = "${file("iam/route53_policy.json.tpl")}" } resource "aws_iam_policy" "eks_worker_additional_route53_policy" { description = "Allow nodes to update our zone" name = "${module.k8s_cluster01_label.id}-additional-route53-policy" policy = "${data.template_file.eks_worker_additional_route53_policy.rendered}" } ``` which defines the policy; then in the EKS module : ```hcl module "cluster01" { cluster_name = "cluster01" <snip> workers_addtional_policies = [ "${aws_iam_policy.eks_worker_additional_route53_policy.arn}" ] workers_addtional_policies_count = 1 <snip> ```
1 parent efaa3d8 commit bef3c36

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ variable "worker_sg_ingress_from_port" {
168168
default = "1025"
169169
}
170170

171+
variable "workers_additional_policies" {
172+
description = "Additional policies to be added to workers"
173+
type = "list"
174+
default = []
175+
}
176+
177+
variable "workers_additional_policies_count" {
178+
default = 0
179+
}
180+
171181
variable "kubeconfig_aws_authenticator_command" {
172182
description = "Command to use to fetch AWS EKS credentials."
173183
default = "aws-iam-authenticator"

workers.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ resource "aws_iam_role_policy_attachment" "workers_AmazonEC2ContainerRegistryRea
143143
role = "${aws_iam_role.workers.name}"
144144
}
145145

146+
resource "aws_iam_role_policy_attachment" "workers_additional_policies" {
147+
count = "${var.workers_additional_policies_count}"
148+
role = "${aws_iam_role.workers.name}"
149+
policy_arn = "${var.workers_additional_policies[count.index]}"
150+
}
151+
146152
resource "null_resource" "tags_as_list_of_maps" {
147153
count = "${length(keys(var.tags))}"
148154

0 commit comments

Comments
 (0)