Skip to content

Conversation

@avoidik
Copy link

@avoidik avoidik commented Dec 12, 2025

Description

This PR adds --subject-pattern to eksctl create iamserviceaccount.

#8628

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the userdocs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes
  • (Core team) Added labels for change area (e.g. area/nodegroup) and kind (e.g. kind/improvement)

BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯

  • Backfilled missing tests for code in same general area 🎉
  • Refactored something and made the world a better place 🌟

@avoidik
Copy link
Author

avoidik commented Dec 12, 2025

Example:

eksctl create iamserviceaccount \
    --name crossplane \
    --namespace crossplane-system \
    --cluster "$CLUSTER_NAME" \
    --role-name "$ROLE_NAME" \
    --attach-policy-arn 'arn:aws:iam::aws:policy/AdministratorAccess' \
    --subject-pattern 'provider-aws-*' \
    --role-only \
    --approve

@avoidik avoidik changed the title Allow wildcard matching for service account subject Allow wildcard matching of service account subject Dec 12, 2025
Copy link
Contributor

@NicholasBlaskey NicholasBlaskey left a comment

Choose a reason for hiding this comment

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

Feature looks reasonable to me. Thanks for contributing a fix

Implementation looks good to me just have a comment couples

// instead of the service account name, and StringLike is used instead of StringEquals
// to allow wildcard matching. This only works when using command line flags (not with config files).
// +optional
SubjectPattern string `json:"-"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we can't support this for config too?

// MakeAssumeRolePolicyDocumentWithServiceAccountConditionsAllowingWildcard constructs a trust policy document
// that allows wildcard pattern matching in the subject condition. The subjectPattern should be in the format
// "system:serviceaccount:namespace:name-pattern" where name-pattern can include wildcards like "*".
func (m *OpenIDConnectManager) MakeAssumeRolePolicyDocumentWithServiceAccountConditionsAllowingWildcard(serviceAccountNamespace, subjectPattern string) cft.MapOfInterfaces {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we update MakeAssumeRolePolicyDocumentWithServiceAccountConditions to take subjectPattern instead of creating another function to avoid duplicating some of the logic?

@NicholasBlaskey NicholasBlaskey added the kind/feature New feature or request label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants