Skip to content
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

aws-eks : ALB controller IAM policies created in China using wrong partition #23642

Open
ItielOlenick opened this issue Jan 11, 2023 · 5 comments
Assignees
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. p2

Comments

@ItielOlenick
Copy link

ItielOlenick commented Jan 11, 2023

Describe the bug

When using the CDK to create a EKS cluster and specifying the use of alb controller, upon the creation of the IAM policy for alb controller the following error arises:

Partition "aws" is not valid for resource "arn:aws:ec2:*:*:security-group/*". (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID
: xxxx-xx-xx-xxxxx-xxx-xx-xxx; Proxy: null)

A quick search for "arn:aws:ec2:*:*:security-group/*" in the repo shows a few pages where this is used.

Expected Behavior

A EKS cluster should be successfully created when using CDK to create in China

Current Behavior

Partition "aws" is not valid for resource "arn:aws:ec2:*:*:security-group/*". (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID
: xxxx-xx-xx-xxxxx-xxx-xx-xxx; Proxy: null)

Reproduction Steps

Try to create a EKS cluster in China with the ALB controller enabled:

self.eks_cluster = aws_eks.Cluster(
    self,
    id="cvat-in-k8s-cluster",
    version=aws_eks.KubernetesVersion.V1_21,
    vpc=self.vpc,
    vpc_subnets=[aws_ec2.SubnetSelection(subnet_type=aws_ec2.SubnetType.PRIVATE_WITH_NAT)],
    default_capacity=2,
    alb_controller=aws_eks.AlbControllerOptions(
        version=aws_eks.AlbControllerVersion.V2_4_1
    ),
    endpoint_access=aws_eks.EndpointAccess.PUBLIC_AND_PRIVATE.only_from(*CIDR_BLOCKS),
)

Possible Solution

Check if the region is in China, and if so change the partition to aws-cn

Additional Information/Context

No response

CDK CLI Version

2.37.1

Framework Version

No response

Node.js Version

15

OS

Linux

Language

Python

Language Version

No response

Other information

No response

@ItielOlenick ItielOlenick added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 11, 2023
@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Jan 11, 2023
@ItielOlenick ItielOlenick changed the title aws-eks : Service account's IAM policies created in China using wrong partition aws-eks : ALB controller IAM policies created in China using wrong partition Jan 11, 2023
@pahud
Copy link
Contributor

pahud commented Jan 30, 2023

Thanks for your report. Which aws region were you deploying to? cn-north-1 or cn-northwest-1 ?

@pahud pahud added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Jan 30, 2023
@pahud pahud self-assigned this Jan 30, 2023
@zorrofox
Copy link
Contributor

zorrofox commented Feb 4, 2023

I think either cn-north-1 or cn-northwest-1 for China partition is not work for the default IAM policy, as the policy document is come from this line

const policy: any = props.policy ?? JSON.parse(fs.readFileSync(path.join(__dirname, 'addons', `alb-iam_policy-${props.version.version}.json`), 'utf8'));

And all these version policy documents are come from ALB ingress repo for this file, they are all for global partition not for GOV or China partitions. There have another policy document in the repo is for the China partition.

@zorrofox
Copy link
Contributor

zorrofox commented Feb 4, 2023

Same issue for #22520

@ItielOlenick
Copy link
Author

For me this happened in cn-northwest-1, But like @zorrofox said, this has to do with the use of the wrong partition in the alb policy.

Taking a quick look at https://github.com/aws/aws-cdk/search?q=arn%3Aaws%3Aec2%3A*%3A*%3Asecurity-group%2F* shows that nothing is done to check the partition in the alb-iam_policy files which results in the use of the wrong one.

@zorrofox
Copy link
Contributor

Can we just use the commercial partition policy files to substitute with China or GOV partitions? Or we just like commercial partition to host all the policy files for China and GOV partitions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. p2
Projects
None yet
Development

No branches or pull requests

3 participants