Skip to content

SREP-3880: Request AWS additional SQS permissions for ROSA Managed Policies (Spot Instance Support)#8134

Open
ratnam915 wants to merge 4 commits intoopenshift:mainfrom
ratnam915:feature/SREP-3880
Open

SREP-3880: Request AWS additional SQS permissions for ROSA Managed Policies (Spot Instance Support)#8134
ratnam915 wants to merge 4 commits intoopenshift:mainfrom
ratnam915:feature/SREP-3880

Conversation

@ratnam915
Copy link
Copy Markdown

@ratnam915 ratnam915 commented Mar 31, 2026

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
    • SQS delete/receive permissions are now restricted by a required resource tag, tightening access to queues that carry that tag.
  • New Features
    • Added API support to tag queues so resources can be marked for the new tag-restricted operations.
  • Tests
    • E2E tests updated to create queues with the required tag to validate the tag-based access restriction.

@openshift-ci-robot
Copy link
Copy Markdown

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 31, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 31, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Mar 31, 2026

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9fd330d8-2fba-4b36-98d4-1fb6ecf62c9b

📥 Commits

Reviewing files that changed from the base of the PR and between 45db83b and 70f7bc1.

📒 Files selected for processing (1)
  • test/e2e/nodepool_spot_termination_handler_test.go

📝 Walkthrough

Walkthrough

The IAM policy nodePoolPolicy in cmd/infra/aws/iam.go was changed: sqs:DeleteMessage and sqs:ReceiveMessage were removed from the main actions list and added in a separate statement (Sid: NodePoolSQSActions) that allows those actions on "*" only when the queue has the tag aws:ResourceTag/red-hat equal to "true". The exported SQSAPI interface (support/awsapi/sqs.go) gained a TagQueue method and the delegating client generator was updated to include TagQueue for SQS. The e2e test now tags the created SQS queue with red-hat=true.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Test as Test/Operator
participant IAM as AWS IAM
participant SQS as SQS Service
participant NodePool as NodePool (instance)

Test->>SQS: CreateQueue (Tags: red-hat=true)
SQS-->>Test: Queue URL
Test->>IAM: Attach nodePoolPolicy (includes condition on aws:ResourceTag/red-hat == "true")
Note right of IAM: Policy contains NodePoolSQSActions for Receive/Delete with Condition
NodePool->>SQS: ReceiveMessage / DeleteMessage
SQS->>IAM: Evaluate request (check aws:ResourceTag/red-hat)
IAM-->>SQS: Allow (if tag == "true") or Deny
SQS-->>NodePool: Return message or AccessDenied
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot added do-not-merge/needs-area area/cli Indicates the PR includes changes for CLI labels Mar 31, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 31, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ratnam915
Once this PR has been reviewed and has the lgtm label, please assign jparrill for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added area/platform/aws PR/issue for AWS (AWSPlatform) platform and removed do-not-merge/needs-area labels Mar 31, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.47%. Comparing base (7ce6015) to head (70f7bc1).
⚠️ Report is 212 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8134      +/-   ##
==========================================
+ Coverage   26.85%   28.47%   +1.62%     
==========================================
  Files        1090     1099       +9     
  Lines      105254   108872    +3618     
==========================================
+ Hits        28263    31000    +2737     
- Misses      74563    75248     +685     
- Partials     2428     2624     +196     
Files with missing lines Coverage Δ
cmd/infra/aws/delegatingclientgenerator/main.go 0.00% <ø> (ø)
cmd/infra/aws/iam.go 0.00% <ø> (ø)

... and 76 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread cmd/infra/aws/iam.go Outdated
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be red-hat: true since it is not actually redhat managed it is more like a shared resource. Would that be a correct?

Managed tag is mostly used for resources created as part of install or RH setup instead of customer input

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

red-hat-managed: true is for things we manage.
red-hat: true is for things that are part of the platform but not necessarily managed by Red Hat.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those perms are for selfhosted hcp, they don't impact rosa in any way.
You'll want to include that in the rosa managed policy. Besides, what guarantees the sqs has that tag in rosa?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdbranco @arendej : This has been fixed now, thanks for the suggestion.

@enxebre : You're right — the inline policy in iam.go is for self-hosted HCP and doesn't directly impact ROSA, which uses AWS managed policies. The managed policy update to
ROSANodePoolManagementPolicy is being tracked separately via the AWS submission process https://redhat.atlassian.net/browse/SREP-3880?focusedCommentId=16584538

This change aligns the self-hosted inline policy with the tag condition that will be included in the managed policy update, so that dev/test environments using inline
policies surface any permission issues early rather than only in ROSA with managed policies.

Add required IAM permissions to support infrastructure provisioning.
Correct IAM permission configuration per review comments.
@ratnam915 ratnam915 force-pushed the feature/SREP-3880 branch from 803e11e to ce32fa8 Compare April 6, 2026 09:47
@ratnam915
Copy link
Copy Markdown
Author

@gdbranco @arendej @enxebre : Could you help out with the review for the latest changes

@ratnam915 ratnam915 marked this pull request as ready for review April 8, 2026 11:27
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 8, 2026
@openshift-ci openshift-ci bot requested review from devguyio and jparrill April 8, 2026 11:28
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 8, 2026

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • Updated cloud access control policies to enforce stricter restrictions on queue service operations using resource-level tagging.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/infra/aws/iam.go`:
- Line 526: The IAM policy condition uses the wrong tag key
"aws:ResourceTag/red-hat"; change it to "aws:ResourceTag/red-hat-managed" so it
matches the actual resource tag used across the codebase (see where
support/awsutil/platform.go checks tag.Key == "red-hat-managed" and
cmd/cluster/aws/create.go appends red-hat-managed=true); update the string
literal in the IAM policy definition in cmd/infra/aws/iam.go to
"aws:ResourceTag/red-hat-managed".
- Around line 516-529: Add a TagQueue method to the SQSAPI interface and ensure
all queue creation paths tag queues with "red-hat":"true"; specifically, modify
support/awsapi/sqs.go to add TagQueue(ctx context.Context, input
*sqs.TagQueueInput) (*sqs.TagQueueOutput, error) (or equivalent signature used
elsewhere), then update every place that creates or initializes queues (e.g.,
calls to CreateQueue or any helper like CreateSQSQueue/CreateQueueIfNotExists)
to include the tag either in CreateQueueInput.Tags or immediately call
SQSAPI.TagQueue after creation using the returned QueueUrl/QueueArn; ensure
callers import and use the new method name (TagQueue) and handle errors returned
from tagging.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 67d1a0bb-22ad-4ebc-b0dc-3188c297e00b

📥 Commits

Reviewing files that changed from the base of the PR and between 51af991 and ce32fa8.

📒 Files selected for processing (1)
  • cmd/infra/aws/iam.go

Comment thread cmd/infra/aws/iam.go
Comment on lines +516 to +529
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat": "true"
}
}
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for SQS queue tagging implementation and tag key usage

# Search for SQS tagging operations
echo "=== Searching for SQS TagQueue or TagResource calls ==="
rg -n 'TagQueue|TagResource' --type=go -C3

echo -e "\n=== Searching for red-hat tag key usage ==="
rg -n '"red-hat"' --type=go -C3

echo -e "\n=== Searching for SQS queue creation with tags ==="
rg -nP 'CreateQueue.*tags?|tags?.*CreateQueue' --type=go -C5

echo -e "\n=== Searching for QueueAttributes or Tags in SQS operations ==="
rg -n 'QueueAttributes|Tags.*sqs' --type=go -C3

Repository: openshift/hypershift

Length of output: 50377


🏁 Script executed:

#!/bin/bash

# Find the SQSAPI interface definition
echo "=== SQSAPI interface in support/awsapi/sqs.go ==="
find . -path ./vendor -prune -o -name "sqs.go" -type f -print | grep -v vendor | head -5
for file in $(find . -path ./vendor -prune -o -name "sqs.go" -type f -print | grep -v vendor); do
  echo "File: $file"
  cat "$file"
done

echo -e "\n=== Searching for TagQueue calls outside vendor directory ==="
rg -n 'TagQueue' --type=go --glob='!vendor/**' -C2

echo -e "\n=== Searching for red-hat tag assignment outside vendor ==="
rg -n '"red-hat"' --type=go --glob='!vendor/**' -B2 -A2

echo -e "\n=== Search for SQS queue creation with tags ==="
rg -n 'CreateQueue' --type=go --glob='!vendor/**' -B3 -A5

Repository: openshift/hypershift

Length of output: 4459


Add TagQueue method to SQSAPI interface and implement queue tagging with the red-hat: true tag.

The IAM policy restricts sqs:DeleteMessage and sqs:ReceiveMessage operations to queues tagged with red-hat: true. However, the SQSAPI interface lacks a TagQueue method, and there is no code implementing queue tagging. This will cause permission denied errors at runtime when the nodePool attempts to receive or delete messages on untagged queues.

The SQSAPI interface in support/awsapi/sqs.go must include TagQueue, and all SQS queue creation in the application must apply the red-hat: true tag (either during queue creation via the Tags parameter in CreateQueueInput or immediately after creation via TagQueue).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/infra/aws/iam.go` around lines 516 - 529, Add a TagQueue method to the
SQSAPI interface and ensure all queue creation paths tag queues with
"red-hat":"true"; specifically, modify support/awsapi/sqs.go to add TagQueue(ctx
context.Context, input *sqs.TagQueueInput) (*sqs.TagQueueOutput, error) (or
equivalent signature used elsewhere), then update every place that creates or
initializes queues (e.g., calls to CreateQueue or any helper like
CreateSQSQueue/CreateQueueIfNotExists) to include the tag either in
CreateQueueInput.Tags or immediately call SQSAPI.TagQueue after creation using
the returned QueueUrl/QueueArn; ensure callers import and use the new method
name (TagQueue) and handle errors returned from tagging.

Comment thread cmd/infra/aws/iam.go
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat": "true"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify tag key consistency and check for both variants

echo "=== Searching for 'red-hat-managed' tag usage ==="
rg -n 'red-hat-managed' --type=go -C3

echo -e "\n=== Searching for 'red-hat' tag usage (without '-managed') ==="
rg -n '"red-hat":\s*"true"' --type=go -C3

echo -e "\n=== Checking IAM policies for tag conditions ==="
rg -nP 'aws:ResourceTag/(red-hat|red-hat-managed)' --type=go -C3

Repository: openshift/hypershift

Length of output: 10216


Fix tag key mismatch in IAM policy condition.

The IAM policy at line 526 uses aws:ResourceTag/red-hat, but the actual infrastructure tags across the codebase use red-hat-managed=true:

  • support/awsutil/platform.go:14 checks for tag.Key == "red-hat-managed"
  • cmd/cluster/aws/create.go:121 appends red-hat-managed=true to resource tags
  • The webhook and tests all reference red-hat-managed

The IAM condition must be changed to aws:ResourceTag/red-hat-managed to match the tags actually applied to resources. With the current code, the policy condition will never match, resulting in access denied errors.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/infra/aws/iam.go` at line 526, The IAM policy condition uses the wrong
tag key "aws:ResourceTag/red-hat"; change it to
"aws:ResourceTag/red-hat-managed" so it matches the actual resource tag used
across the codebase (see where support/awsutil/platform.go checks tag.Key ==
"red-hat-managed" and cmd/cluster/aws/create.go appends red-hat-managed=true);
update the string literal in the IAM policy definition in cmd/infra/aws/iam.go
to "aws:ResourceTag/red-hat-managed".

@openshift-ci openshift-ci bot added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing labels Apr 9, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 9, 2026

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • Tightened cloud access control: SQS delete/receive permissions now require a specific resource tag to apply.
  • New Features
  • Added support for tagging queues via the service API.
  • Tests
  • End-to-end tests updated to create queues with the required tag to validate the new restrictions.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@ratnam915 ratnam915 force-pushed the feature/SREP-3880 branch from ab28b72 to 585df87 Compare April 9, 2026 05:16
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 9, 2026

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • Tightened SQS access: delete/receive permissions now apply only when a specific resource tag is present.
  • New Features
  • Added API support for tagging queues.
  • Tests
  • E2E tests updated to create queues with the required tag to validate the new tag-based access restriction.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Add TagQueue method to SQSAPI interface in support/awsapi/sqs.go and
tag SQS queues with "red-hat":"true" at creation time in the e2e test
to match the IAM policy condition on aws:ResourceTag/red-hat.
@ratnam915 ratnam915 force-pushed the feature/SREP-3880 branch from 585df87 to 45db83b Compare April 9, 2026 05:37
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 9, 2026

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • SQS delete/receive permissions are now restricted by a required resource tag, tightening access to queues that carry that tag.
  • New Features
  • Added API support to tag queues so resources can be marked for the new tag-restricted operations.
  • Tests
  • E2E tests updated to create queues with the required tag to validate the tag-based access restriction.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/nodepool_spot_termination_handler_test.go`:
- Around line 151-153: The test attaches an inline IAM policy that grants
sqs:ReceiveMessage and sqs:DeleteMessage without enforcing the
aws:ResourceTag/red-hat tag condition, so the test bypasses the production gate;
update the test's inline policy (the block at Lines ~113–125 that grants SQS
actions) to include a Condition enforcing "StringEquals":
{"aws:ResourceTag/red-hat": "true"} for those actions (or alternately scope the
policy to the specific SQS resource ARN that has the Tags map set in the test),
keeping the Tags map (the "red-hat": "true" entry around Line 151) as the tag
that satisfies the condition.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: a898f08c-512c-465e-91dc-2cf1415f7727

📥 Commits

Reviewing files that changed from the base of the PR and between 585df87 and 45db83b.

📒 Files selected for processing (3)
  • cmd/infra/aws/delegatingclientgenerator/main.go
  • support/awsapi/sqs.go
  • test/e2e/nodepool_spot_termination_handler_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • support/awsapi/sqs.go

Comment thread test/e2e/nodepool_spot_termination_handler_test.go
Add StringEquals condition for aws:ResourceTag/red-hat to the test's
inline IAM policy so it matches the production gate rather than
granting unconditional SQS access.
@ratnam915 ratnam915 closed this Apr 9, 2026
@ratnam915 ratnam915 reopened this Apr 9, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 9, 2026

@ratnam915: This pull request references SREP-3880 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

PR Refinement: Scope SQS Permissions with red-hat-managed Tag Condition in Nodepool Inline PolicyTarget

Summary

Scope the AWS IAM actions sqs:DeleteMessage and sqs:ReceiveMessage within the nodePoolPolicy inline policy by applying an aws:ResourceTag/red-hat-managed: "true" condition. This change ensures the development/test inline policy aligns with the security posture update in the upcoming ROSANodePoolManagementPolicy managed policy.Change Description
Remove sqs:DeleteMessage and sqs:ReceiveMessage from the existing general statement (the one encompassing all EC2 actions and Resource: [""]).
Add a new, separate statement after the existing ones:
{
"Sid": "NodePoolSQSActions",
"Effect": "Allow",
"Action": [
"sqs:DeleteMessage",
"sqs:ReceiveMessage"
],
"Resource": "
",
"Condition": {
"StringEquals": {
"aws:ResourceTag/red-hat-managed": "true"
}
}
}

Reference
Enhancement: https://github.com/openshift/enhancements/pull/1951
NTH Implementation: https://github.com/openshift/hypershift/pull/7567
API Changes: https://github.com/openshift/hypershift/pull/7625
Jira: OCPSTRAT-1677 / SREP-698

Summary by CodeRabbit

  • Chores
  • SQS delete/receive permissions are now restricted by a required resource tag, tightening access to queues that carry that tag.
  • New Features
  • Added API support to tag queues so resources can be marked for the new tag-restricted operations.
  • Tests
  • E2E tests updated to create queues with the required tag to validate the tag-based access restriction.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 17, 2026

@ratnam915: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/platform/aws PR/issue for AWS (AWSPlatform) platform area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants