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

feat: Add irsa_tag_values variable #2584

Merged
merged 2 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions modules/karpenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ No modules.
| <a name="input_irsa_ssm_parameter_arns"></a> [irsa\_ssm\_parameter\_arns](#input\_irsa\_ssm\_parameter\_arns) | List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter | `list(string)` | <pre>[<br> "arn:aws:ssm:*:*:parameter/aws/service/*"<br>]</pre> | no |
| <a name="input_irsa_subnet_account_id"></a> [irsa\_subnet\_account\_id](#input\_irsa\_subnet\_account\_id) | Account ID of where the subnets Karpenter will utilize resides. Used when subnets are shared from another account | `string` | `""` | no |
| <a name="input_irsa_tag_key"></a> [irsa\_tag\_key](#input\_irsa\_tag\_key) | Tag key (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner | `string` | `"karpenter.sh/discovery"` | no |
| <a name="input_irsa_tag_values"></a> [irsa\_tag\_values](#input\_irsa\_tag\_values) | Tag value (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner. Defaults to cluster name when not set. | `list(string)` | `null` | no |
| <a name="input_irsa_tags"></a> [irsa\_tags](#input\_irsa\_tags) | A map of additional tags to add the the IAM role for service accounts | `map(any)` | `{}` | no |
| <a name="input_irsa_use_name_prefix"></a> [irsa\_use\_name\_prefix](#input\_irsa\_use\_name\_prefix) | Determines whether the IAM role for service accounts name (`irsa_name`) is used as a prefix | `bool` | `true` | no |
| <a name="input_policies"></a> [policies](#input\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |
Expand Down
8 changes: 6 additions & 2 deletions modules/karpenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ resource "aws_iam_role" "irsa" {
tags = merge(var.tags, var.irsa_tags)
}

locals {
irsa_tag_values = var.irsa_tag_values == null ? [var.cluster_name] : var.irsa_tag_values
tongueroo marked this conversation as resolved.
Show resolved Hide resolved
}

data "aws_iam_policy_document" "irsa" {
count = local.create_irsa ? 1 : 0

Expand Down Expand Up @@ -97,7 +101,7 @@ data "aws_iam_policy_document" "irsa" {
condition {
test = "StringEquals"
variable = "ec2:ResourceTag/${var.irsa_tag_key}"
values = [var.cluster_name]
values = local.irsa_tag_values
}
}

Expand All @@ -110,7 +114,7 @@ data "aws_iam_policy_document" "irsa" {
condition {
test = "StringEquals"
variable = "ec2:ResourceTag/${var.irsa_tag_key}"
values = [var.cluster_name]
values = local.irsa_tag_values
}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/karpenter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ variable "irsa_tag_key" {
default = "karpenter.sh/discovery"
}

variable "irsa_tag_values" {
description = "Tag value (`{key = value}`) applied to resources launched by Karpenter through the Karpenter provisioner. Defaults to cluster name when not set."
tongueroo marked this conversation as resolved.
Show resolved Hide resolved
type = list(string)
default = null
}

variable "irsa_ssm_parameter_arns" {
description = "List of SSM Parameter ARNs that contain AMI IDs launched by Karpenter"
type = list(string)
Expand Down