Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding optional role_name parameter #35

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,10 @@ variable "roles" {
}))
default = []
description = "RBAC roles that give secret access in other namespaces to the lb controller"
}

variable "role_name" {
type = string
default = null
description = "Optional Parameter to override the naming convention used '<cluster-name>-alb-ingress' role name"
}
8 changes: 6 additions & 2 deletions iam.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
role_name = var.role_name==null ? "${var.cluster_name}-alb-ingress" : var.role_name
}

# Policy
data "aws_iam_policy_document" "lb_controller" {
count = var.enabled ? 1 : 0
Expand Down Expand Up @@ -326,7 +330,7 @@ data "aws_iam_policy_document" "lb_controller" {
resource "aws_iam_policy" "lb_controller" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0
name = "${var.cluster_name}-alb-ingress"
name = local.role_name
path = "/"
description = "Policy for alb-ingress service"

Expand Down Expand Up @@ -360,7 +364,7 @@ data "aws_iam_policy_document" "lb_controller_assume" {

resource "aws_iam_role" "lb_controller" {
count = var.enabled ? 1 : 0
name = "${var.cluster_name}-alb-ingress"
name = local.role_name
assume_role_policy = data.aws_iam_policy_document.lb_controller_assume[0].json
}

Expand Down