Skip to content

feat:[PEA-358] Allow k8s lambda to assume 'ro' role#2399

Closed
kevin-paladin wants to merge 1 commit into
masterfrom
PEA-358-add-eks-support
Closed

feat:[PEA-358] Allow k8s lambda to assume 'ro' role#2399
kevin-paladin wants to merge 1 commit into
masterfrom
PEA-358-add-eks-support

Conversation

@kevin-paladin

@kevin-paladin kevin-paladin commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Add the k8s lambda role to the ro role, allowing the k8s lambda to assume the PaladinCloudIntegrationRole in the remote account, which is needed to get a valid K8s token.

Summary by CodeRabbit

  • Bug Fixes
    • Expanded role access so the service can assume permissions from an additional approved environment role.
    • Improved compatibility with Kubernetes container-based deployments by supporting both existing and new IAM role paths.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The IAM assume-role policy in all_read_role.py was updated to allow an additional AWS principal to assume the role, expanding the identifiers list from a single ECS role ARN to include a second role ARN constructed from account and environment settings.

Changes

IAM Policy Update

Layer / File(s) Summary
Add secondary principal to assume-role policy
installer/resources/iam/all_read_role.py
The AWS principal identifiers list now includes both the existing ECS role ARN and a newly constructed role ARN (...-svc-plugin-k8s-containers-role) using Settings.ACCOUNT_ID and Settings.STACK_ENV.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A hop, a skip, a policy tweak,
One more role now gets to speak.
ARNs aligned, two paths allowed,
This little rabbit hops out loud! 🐇
Trust extended, safe and neat.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description states the change, but it omits the required template sections like Problem, Solution, issue link, testing, and checklist. Expand the PR description to fill the template: add Problem, Solution, Fixes issue, Type of change, testing details, checklist, and docs notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding the k8s lambda role to assume the ro role.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PEA-358-add-eks-support

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@installer/resources/iam/all_read_role.py`:
- Line 13: The role ARN assembly in the class body references
Settings.ACCOUNT_ID and Settings.STACK_ENV before Settings is imported, which
will cause a NameError during module load. Add the missing module-level import
for Settings in all_read_role.py before the class definition that builds the
ARN, and keep the reference in the policy string unchanged so policy generation
can complete.
🪄 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 UI

Review profile: CHILL

Plan: Pro

Run ID: 60244640-1d30-4846-87b3-4b94280b77aa

📥 Commits

Reviewing files that changed from the base of the PR and between 7f6634e and bacd572.

📒 Files selected for processing (1)
  • installer/resources/iam/all_read_role.py

'identifiers': [ECSRole.get_output_attr('arn')]
'identifiers': [
ECSRole.get_output_attr('arn'),
"arn:aws:iam::" + Settings.ACCOUNT_ID + ":role/" + Settings.STACK_ENV + "-svc-plugin-k8s-containers-role"

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.

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate the canonical Settings definition/import pattern, then add the matching import
# to installer/resources/iam/all_read_role.py.
rg -n --type py -C2 'class Settings\b|Settings\s*=' .
rg -n --type py -C2 'from .* import .*Settings|import .*Settings' .

Repository: PaladinCloud/CE

Length of output: 29629


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the target file and the closest matching IAM resource for import patterns.
sed -n '1,120p' installer/resources/iam/all_read_role.py
printf '\n--- base_role.py ---\n'
sed -n '1,80p' installer/resources/iam/base_role.py
printf '\n--- ecs_role.py ---\n'
sed -n '1,80p' installer/resources/iam/ecs_role.py

# Show exact references to Settings in the target file, if any.
printf '\n--- Settings refs in all_read_role.py ---\n'
rg -n 'Settings|ECSRole|principals|identifiers' installer/resources/iam/all_read_role.py

Repository: PaladinCloud/CE

Length of output: 9701


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Read the reviewed file and dependency files to determine whether Settings is imported.
for f in installer/resources/iam/all_read_role.py installer/resources/iam/base_role.py installer/resources/iam/ecs_role.py; do
  echo "--- $f ---"
  cat -n "$f"
  echo
done

# Check whether the target file imports Settings directly or via wildcard.
echo "--- import lines in all_read_role.py ---"
rg -n '^(from|import) ' installer/resources/iam/all_read_role.py

Repository: PaladinCloud/CE

Length of output: 15408


Import Settings before using it here.

Settings.ACCOUNT_ID and Settings.STACK_ENV are referenced without a module-level import, so this class body will raise NameError during import and block policy generation.

🧰 Tools
🪛 Ruff (0.15.20)

[error] 13-13: Undefined name Settings

(F821)


[error] 13-13: Undefined name Settings

(F821)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@installer/resources/iam/all_read_role.py` at line 13, The role ARN assembly
in the class body references Settings.ACCOUNT_ID and Settings.STACK_ENV before
Settings is imported, which will cause a NameError during module load. Add the
missing module-level import for Settings in all_read_role.py before the class
definition that builds the ARN, and keep the reference in the policy string
unchanged so policy generation can complete.

Source: Linters/SAST tools

@kevin-paladin kevin-paladin deleted the PEA-358-add-eks-support branch July 7, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant