fix: Karpenter enable_spot_termination = false should not result in an error (#2907)

* Add condition for statement if enable_spot_termination is true

* Update modules/karpenter/main.tf

---------

Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
This commit is contained in:
Nick Nikitas
2024-02-08 02:32:47 +02:00
committed by GitHub
parent a9212a423f
commit 671fc6e627

View File

@@ -252,9 +252,12 @@ data "aws_iam_policy_document" "controller" {
actions = ["pricing:GetProducts"] actions = ["pricing:GetProducts"]
} }
statement { dynamic "statement" {
for_each = local.enable_spot_termination ? [1] : []
content {
sid = "AllowInterruptionQueueActions" sid = "AllowInterruptionQueueActions"
resources = [aws_sqs_queue.this[0].arn] resources = [try(aws_sqs_queue.this[0].arn, null)]
actions = [ actions = [
"sqs:DeleteMessage", "sqs:DeleteMessage",
"sqs:GetQueueAttributes", "sqs:GetQueueAttributes",
@@ -262,6 +265,7 @@ data "aws_iam_policy_document" "controller" {
"sqs:ReceiveMessage" "sqs:ReceiveMessage"
] ]
} }
}
statement { statement {
sid = "AllowPassingInstanceRole" sid = "AllowPassingInstanceRole"