From 0bd7348ad9cc828da3109834a22f18b1b8300b84 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Fri, 29 Oct 2021 17:46:33 -0500 Subject: [PATCH] Fix ARN partition in SQS queue policy --- pkg/model/awsmodel/nodeterminationhandler.go | 3 ++- .../update_cluster/nth_sqs_resources/cloudformation.json | 2 +- ...ueue_nthsqsresources-longclustername-example-com-nth_policy | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/model/awsmodel/nodeterminationhandler.go b/pkg/model/awsmodel/nodeterminationhandler.go index ae423d34ae..b5409a78d8 100644 --- a/pkg/model/awsmodel/nodeterminationhandler.go +++ b/pkg/model/awsmodel/nodeterminationhandler.go @@ -38,7 +38,7 @@ const ( "Service": ["events.amazonaws.com", "sqs.amazonaws.com"] }, "Action": "sqs:SendMessage", - "Resource": "arn:aws:sqs:{{ AWS_REGION }}:{{ ACCOUNT_ID }}:{{ SQS_QUEUE_NAME }}" + "Resource": "arn:{{ AWS_PARTITION }}:sqs:{{ AWS_REGION }}:{{ ACCOUNT_ID }}:{{ SQS_QUEUE_NAME }}" }] }` DefaultMessageRetentionPeriod = 300 @@ -116,6 +116,7 @@ func (b *NodeTerminationHandlerBuilder) configureASG(c *fi.ModelBuilderContext, func (b *NodeTerminationHandlerBuilder) build(c *fi.ModelBuilderContext) error { queueName := model.QueueNamePrefix(b.ClusterName()) + "-nth" policy := strings.ReplaceAll(NTHTemplate, "{{ AWS_REGION }}", b.Region) + policy = strings.ReplaceAll(policy, "{{ AWS_PARTITION }}", b.AWSPartition) policy = strings.ReplaceAll(policy, "{{ ACCOUNT_ID }}", b.AWSAccountID) policy = strings.ReplaceAll(policy, "{{ SQS_QUEUE_NAME }}", queueName) diff --git a/tests/integration/update_cluster/nth_sqs_resources/cloudformation.json b/tests/integration/update_cluster/nth_sqs_resources/cloudformation.json index 9b835c394d..8bf0a3a73f 100644 --- a/tests/integration/update_cluster/nth_sqs_resources/cloudformation.json +++ b/tests/integration/update_cluster/nth_sqs_resources/cloudformation.json @@ -1468,7 +1468,7 @@ "sqs.amazonaws.com" ] }, - "Resource": "arn:aws:sqs:us-test-1:123456789012:nthsqsresources-longclustername-example-com-nth" + "Resource": "arn:aws-test:sqs:us-test-1:123456789012:nthsqsresources-longclustername-example-com-nth" } ], "Version": "2012-10-17" diff --git a/tests/integration/update_cluster/nth_sqs_resources/data/aws_sqs_queue_nthsqsresources-longclustername-example-com-nth_policy b/tests/integration/update_cluster/nth_sqs_resources/data/aws_sqs_queue_nthsqsresources-longclustername-example-com-nth_policy index 06b0619ae8..c73cbc4c57 100644 --- a/tests/integration/update_cluster/nth_sqs_resources/data/aws_sqs_queue_nthsqsresources-longclustername-example-com-nth_policy +++ b/tests/integration/update_cluster/nth_sqs_resources/data/aws_sqs_queue_nthsqsresources-longclustername-example-com-nth_policy @@ -6,6 +6,6 @@ "Service": ["events.amazonaws.com", "sqs.amazonaws.com"] }, "Action": "sqs:SendMessage", - "Resource": "arn:aws:sqs:us-test-1:123456789012:nthsqsresources-longclustername-example-com-nth" + "Resource": "arn:aws-test:sqs:us-test-1:123456789012:nthsqsresources-longclustername-example-com-nth" }] }