-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(eks): policy does not exist or is not attachable in China regions #24759
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Exemption Request |
The pull request linter fails with the following errors:
PRs must pass status checks before we can provide a meaningful review. If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing |
import { RegionInfo } from '@aws-cdk/region-info'; | ||
|
||
export function EcrPublicAvailable(region: any): boolean { | ||
if (region && !Token.isUnresolved(region)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any handling we can do for when a token is being used? It seems like it's a fairly common use case and this fix would still result in an error for those users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes thank you for the heads up. I will fix this soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheRealAmazonKendra Correct me if I am wrong. We probably can't conditionally attach the managed policy if we can't tell the region in the synth stage(region agnostic). In this case, we probably should always assume EcrPublicAvailable to be false
and not attach the AmazonElasticContainerRegistryPublicReadOnly
policy:
export function EcrPublicAvailable(region: any): boolean {
if (region && !Token.isUnresolved(region)) {
return RegionInfo.get(region).ecrPublicAvailable;
} else {
// we can't determine region in the synth time, assuming false.
return false;
}
}
And we should not run this as well:
f"aws ecr-public get-login-password --region us-east-1 | " \ |
Another option is to throw an error if stack.region
is not specified just like below. But this will make stack.region always required when we create the eks.Cluster(breaking changes?).
aws-cdk/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts
Lines 335 to 337 in 0f56583
if (Token.isUnresolved(stack.region)) { | |
throw new Error(`region (${stack.region}) cannot be a token and must be configured to one of: ${supportedRegions}`); | |
} |
What do you think?
close in favor of #25170 |
As ECR Public is not available in China regions and govcloud,
AmazonElasticContainerRegistryPublicReadOnly
is not available and should not be attached to the role. This PR implements aRegionInfo
method to determine if ECR public is available in current region and conditionally attachAmazonElasticContainerRegistryPublicReadOnly
policy to the role.Closes #24743 #24808
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license