Honour permissionPolicyName for pod identity inline IAM policies#8675
Honour permissionPolicyName for pod identity inline IAM policies#8675ShiriNmi1520 wants to merge 5 commits intoeksctl-io:mainfrom
Conversation
|
Hello ShiriNmi1520 👋 Thank you for opening a Pull Request in |
|
I'll mark this pull request as a draft until I finish manual testing. Once completed, I'll update the description with relevant testing snippets. |
| }, | ||
| "type": "array" | ||
| }, | ||
| "permissionPolicyName": { |
There was a problem hiding this comment.
We can add a validation for permissionPolicyName that permissionPolicy is present, or fail. Since the permissionPolicyName is only used when the permissionPolicy is set.
There was a problem hiding this comment.
Implemented the function validatePermissionPolicyName, which returns an error if permissionPolicyName is set without permissionPolicy. This function is integrated into both the iam.podIdentityAssociations and addons[].podIdentityAssociations configuration paths.
| b.WriteRune(r) | ||
| } | ||
| } | ||
| if b.Len() == 0 { |
There was a problem hiding this comment.
if user creates policyName completely with special character, now this becomes empty and defaults to "Policy1". Might be better to add a log statement here, so user is aware about, why this is defaulted? Or a add this sanitize logic ahead during the validation and fail fast?
There was a problem hiding this comment.
Went with the fail-fast approach. Added validation that permissionPolicyName must contain at least one alphanumeric character — this catches the all-special-characters case early during config validation rather than silently defaulting. The sanitizeResourceName fallback is kept as a safety net, but should now be unreachable for validated input.
|
@ShiriNmi1520 Thanks for raising this PR. LGTM except for couple of comments that I left. Also you need to rebase and fix the lint issue with the dependencies |
Use podIdentityAssociations.permissionPolicyName as the inline policy resource/name when provided, while keeping Policy1 as the default for existing IAM role builders. Add tests to cover custom policy naming and default behaviour. Signed-off-by: Ivan <s20026352@gmail.com>
Add podIdentityAssociations.permissionPolicyName, the PodIdentityAssociation API type, and JSON schema so custom inline policy names are configurable via config files. Signed-off-by: Ivan <s20026352@gmail.com>
Signed-off-by: Ivan <s20026352@gmail.com>
528a35d to
8561ff9
Compare
@kprahulraj Thank you for your review. I have already updated my code based on your feedback. If there is any misunderstanding or if you need any further clarification, please let me know. |
Description
Fixes #8649.
This PR fixes support for custom inline policy names in pod identity associations.
Previously, when
podIdentityAssociations.permissionPolicywas set, the IAM inline policy resource name was always hardcoded toPolicy1, sopermissionPolicyNamewas effectively ignored.Key changes:
pkg/cfn/builder/iam.goNewIAMRoleResourceSetForPodIdentitynow readsspec.PermissionPolicyNameand falls back toPolicy1when empty.AddAllResourcesnow attaches inline policies using the configured name rather than the hardcodedPolicy1.Policy1to avoid regressions.pkg/cfn/builder/iam_test.gopkg/apis/eksctl.io/v1alpha5/iam.gopkg/apis/eksctl.io/v1alpha5/assets/schema.jsonpermissionPolicyNametoPodIdentityAssociationand schema definitions.Testing snippets:
Checklist
BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯