mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-22 17:39:05 +01:00
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>
```
This commit is contained in:
committed by
Max Williams
parent
efaa3d8d60
commit
bef3c36a40
@@ -143,6 +143,12 @@ resource "aws_iam_role_policy_attachment" "workers_AmazonEC2ContainerRegistryRea
|
||||
role = "${aws_iam_role.workers.name}"
|
||||
}
|
||||
|
||||
resource "aws_iam_role_policy_attachment" "workers_additional_policies" {
|
||||
count = "${var.workers_additional_policies_count}"
|
||||
role = "${aws_iam_role.workers.name}"
|
||||
policy_arn = "${var.workers_additional_policies[count.index]}"
|
||||
}
|
||||
|
||||
resource "null_resource" "tags_as_list_of_maps" {
|
||||
count = "${length(keys(var.tags))}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user