Skip to content

Commit 4f9e377

Browse files
Merge pull request #46 from MaterializeInc/nlb-resource-prefix
Fix aws lb controller naming collision
2 parents ae509d1 + e717869 commit 4f9e377

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module "aws_lbc" {
4646
source = "./modules/aws-lbc"
4747
count = var.install_aws_load_balancer_controller ? 1 : 0
4848

49+
name_prefix = "${var.namespace}-${var.environment}"
4950
eks_cluster_name = module.eks.cluster_name
5051
oidc_provider_arn = module.eks.oidc_provider_arn
5152
oidc_issuer_url = module.eks.cluster_oidc_issuer_url

modules/aws-lbc/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_policy" "aws_load_balancer_controller" {
2-
name = var.iam_name
2+
name = "${var.name_prefix}-${var.iam_name}"
33
description = "AWS Load balancer controller"
44
# From https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.11.0/docs/install/iam_policy.json
55
policy = <<EOF
@@ -254,7 +254,7 @@ EOF
254254
}
255255

256256
resource "aws_iam_role" "aws_load_balancer_controller" {
257-
name = var.iam_name
257+
name = "${var.name_prefix}-${var.iam_name}"
258258
assume_role_policy = jsonencode(
259259
{
260260
Version : "2012-10-17",

modules/aws-lbc/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ variable "namespace" {
44
default = "kube-system"
55
}
66

7+
variable "name_prefix" {
8+
description = "Prefix to use for AWS LBC resources"
9+
type = string
10+
default = ""
11+
}
12+
713
variable "service_account_name" {
814
description = "Name of the Kubernetes service account used by the AWS LBC"
915
type = string
@@ -13,7 +19,7 @@ variable "service_account_name" {
1319
variable "iam_name" {
1420
description = "Name of the AWS IAM role and policy"
1521
type = string
16-
default = "aws-load-balancer-controller"
22+
default = "albc"
1723
}
1824

1925
variable "eks_cluster_name" {

0 commit comments

Comments
 (0)