Conversation
`validateAccessPoliciesForRestrictedTypes` listed `AccessEntryType.EC2` alongside `HYBRID_LINUX` and `HYPERPOD_LINUX`, so passing `accessPolicies` to an EC2 type `AccessEntry` (or calling `addAccessPolicies()` on one) threw a ValidationError. The EKS API does support access policies on EC2 type entries -- attaching `AmazonEKSAutoNodePolicy` to an EC2 type entry is the documented way to grant an EKS Auto Mode node class access to the cluster. Removes `EC2` from the restricted list in both `aws-eks` and `aws-eks-v2`, and corrects the enum JSDoc and README notes that claimed otherwise. The aws-eks-v2 README already documented an EC2 type `grantAccess` carrying `AmazonEKSAutoNodePolicy`, an example that threw at synth time. fixes aws#37496
|
Automated review A maintainer will still review this — treat the notes below as a starting point. This PR fixes a bug (issue #37496) where the EKS L2 rejected The change is well-scoped and correct: it relaxes a synth-time validation only, so any program that previously synthesized still produces an identical template, and no public API shape changes. Unit tests cover both the constructor and 🔴 0 blocking · 🟡 0 recommended · ⚪ 0 optional Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews. |
Issue # (if applicable)
Closes #37496.
Reason for this change
AccessEntryrejectedaccessPoliciesonAccessEntryType.EC2entries at synth time, even though the EKS API accepts them.validateAccessPoliciesForRestrictedTypesgroupedEC2withHYBRID_LINUXandHYPERPOD_LINUX:That guard runs from both the
AccessEntryconstructor andaddAccessPolicies(), so either path threwAccess entry type 'EC2' cannot have access policies attached.Attaching
AmazonEKSAutoNodePolicyto anEC2type entry is the documented way to grant an EKS Auto Mode node class access to the cluster — see Create node class access entry, which creates the entry with--type EC2and then associates that policy. The equivalentCfnAccessEntry(Type: "EC2"withAccessPolicies) deploys fine, so the L2 was strictly more restrictive than the resource underneath it and users had to drop to L1 to express it.aws-eks-v2's README already documented exactly this call:directly above a note saying
EC2cannot have policies. That example throws at synth today. README blocks are compiled by Rosetta but never executed, so nothing caught the contradiction.Description of changes
AccessEntryType.EC2fromrestrictedTypesinaws-eksandaws-eks-v2.HYBRID_LINUXandHYPERPOD_LINUXkeep their guard — this PR makes no claim about those.EC2enum JSDoc and the README notes in both modules, which asserted the opposite of the new behaviour.No feature flag. This relaxes a synth-time guard that rejected input CloudFormation would have accepted, so no app that synthesizes today can change behaviour — per CONTRIBUTING, a flag is required for the opposite direction (newly rejecting input that used to work).
Two decisions worth a maintainer's opinion:
AmazonEKSAutoNodePolicybecause it is the documented real-world pairing, on the existing non-Auto-Mode cluster in that test.AmazonEKSViewPolicywould exercise the same code path with less dependence on Auto Mode specifics if you would prefer that.EC2entry to theaws-eks-v2integ test, since its own comments stateEC2requires an Auto Mode cluster. That file gets a comment correction only, no resource change and no snapshot impact.Describe any new or updated permissions being added
None. No IAM policy is generated or changed by CDK here — this only stops CDK from rejecting an
AccessPoliciesvalue the user supplies, which is then passed through toAWS::EKS::AccessEntryunchanged.Description of how you validated changes
Unit tests in both modules —
EC2moved from the two throws-lists into the two allows-lists, so it is now asserted to accept policies both at construction and viaaddAccessPolicies(). 56 tests pass acrossaws-eks/test/access-entry.test.tsandaws-eks-v2/test/access-entry.test.ts.I confirmed the tests are load-bearing rather than vacuous: re-adding
EC2torestrictedTypesfails exactly 3 of them (creates a new AccessEntry for AccessEntryType EC2,allows EC2 type with access policies,allows adding policies to EC2 type via addAccessPolicies()).Integ test: added an
EC2type entry carryingAmazonEKSAutoNodePolicytointeg.eks-grant-access-with-type.ts. The snapshot diff is the two intended resources:Please note: I regenerated the snapshot with
yarn integ --dry-run --update-on-failedand have not deployed to a live EKS cluster, so this is not verified end-to-end against the service. Happy for a maintainer to run it.The snapshot also carries unrelated churn from
mainhaving moved since it was last regenerated: cloud assembly schema 53 → 54 (mainalready has a 53/54 mix), thecreationStack→acknowledged-rulesmetadata change, and re-bundled Lambda handler asset hashes. I checked each file — the nested templates differ only byS3Key, and nothing behavioural changed.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license