Skip to content

Conversation

datty
Copy link
Contributor

@datty datty commented Jul 17, 2025

Description

AWS CN requires both service principals in the IAM policy passrole condition. Added ec2.amazonaws.com as a default principal.

Motivation and Context

Fails to create EC2NodeClasses without this change in AWS CN

{"level":"ERROR","time":"2025-07-17T09:48:10.169Z","logger":"controller","message":"Reconciler error","commit":"a2875e3","controller":"nodeclass.status","controllerGroup":"karpenter.k8s.aws","controllerKind":"EC2NodeClass","EC2NodeClass":{"name":"gpu"},"namespace":"","name":"gpu","reconcileID":"f6a8cdf5-e6c3-4329-bf32-fa1973febf1a","error":"creating instance profile, adding role \"staging-cn-nw-1-kpt-eks-node-group-20250716100915634200000001\" to instance profile \"staging-cn-nw-1-eks_14906149492098168839\", AccessDenied: User: arn:aws-cn:sts::XXX:assumed-role/KarpenterController-20250716132851685200000005/1752742098653173128 is not authorized to perform: iam:PassRole on resource: arn:aws-cn:iam::XXX:role/staging-cn-nw-1-kpt-eks-node-group-20250716100915634200000001 because no identity-based policy allows the iam:PassRole action\n\tstatus code: 403, request id: 0bce511a-7372-4cdb-9585-3415f44102bc"}

Noted in issue #3389, and same fix applied in cloudformation for karpenter aws/karpenter-provider-aws#6839

Resolves #3389

How Has This Been Tested?

Applied to a new cluster in AWS CN cn-northwest-1 region.

  • I have executed pre-commit run -a on my pull request

@bryantbiggs bryantbiggs changed the title Fix: Allow for both amazonaws.com.cn and amazonaws.com conditions in PassRole as required for AWS CN Fix: Allow for both amazonaws.com.cn and amazonaws.com conditions in PassRole as required for AWS CN Jul 17, 2025
@bryantbiggs bryantbiggs changed the title Fix: Allow for both amazonaws.com.cn and amazonaws.com conditions in PassRole as required for AWS CN fix: Allow for both amazonaws.com.cn and amazonaws.com conditions in PassRole as required for AWS CN Jul 17, 2025
Copy link
Member

@bryantbiggs bryantbiggs left a comment

Choose a reason for hiding this comment

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

thank you

@bryantbiggs bryantbiggs merged commit 83b68fd into terraform-aws-modules:master Jul 17, 2025
24 of 26 checks passed
antonbabenko pushed a commit that referenced this pull request Jul 17, 2025
## [20.37.2](v20.37.1...v20.37.2) (2025-07-17)

### Bug Fixes

* Allow for both `amazonaws.com.cn` and `amazonaws.com` conditions in PassRole as required for AWS CN ([#3422](#3422)) ([83b68fd](83b68fd))
@antonbabenko
Copy link
Member

This PR is included in version 20.37.2 🎉

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

China principal DNS suffix .cn missing
3 participants