-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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] Fail to create FargateProfile - Missing permissions for ec2:DescribeSubnets
#7614
Comments
+1 Reproduction Stepsimport * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as eks from '@aws-cdk/aws-eks';
export class CdkPracticeStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'TheVPC', {
cidr: "10.0.0.0/16"
})
const cluster = new eks.FargateCluster(this, 'hello-eks', {
clusterName: "cdk-practice",
vpc: vpc
// defaultCapacityInstance: new ec2.InstanceType("t3.micro")
});
cluster.addResource('mypod', {
apiVersion: 'v1',
kind: 'Pod',
metadata: { name: 'mypod' },
spec: {
containers: [
{
name: 'hello',
image: 'paulbouwer/hello-kubernetes:1.5',
ports: [ { containerPort: 8080 } ]
}
]
}
});
// The code that defines your stack goes here
}
}
Environment
Error |
this is weird I can successfully deploy it in |
I can confirm the same behavior while creating the fargate profile in region const cluster = new eks.Cluster(this, 'Cluster', {
vpc,
mastersRole
})
const clusterResource = cluster.node.defaultChild as cdk.CfnResource
const clusterCreationRole = clusterResource.node.tryFindChild('CreationRole') as iam.Role
clusterCreationRole.addToPolicy(new iam.PolicyStatement({
actions: [ 'ec2:*' ],
resources: [ '*' ],
})) |
@eduardomourar thanks for the feedback. As Fargate profile would only associate with private subnets, if no PR underway. |
After checking the cloudtrail logs, the creation role will also need |
Now the question is, how can we determine if there are private subnets associated with this cluster? If we can check this, we can throw errors and avoid this error: Wondering if we can do this way const privateSubnets = cluster.vpc.selectSubnets({ subnetType: ec2.SubnetType.PRIVATE }).subnetIds
if (!privateSubnets || privateSubnets.length === 0) {
throw new Error('Fargate profile requires at least one private subnet but no private subnets found from the subnetSelection')
} @eladb any comments? |
Can we just add those permissions always? |
Yes, looks like adding the additional |
Creating fargate profile without specifying `subnetSelection` will require extra iam policy to allow the iam role to describe subnets and route tables to select private subnets. This PR adds the required `ec2:DescribeRouteTables` for the cluster creation role. Closes #7614
ec2:DescribeSubnets
ec2:DescribeSubnets
We just annouced the Fargate support for Amazon EKS in 4 additional regions and I was trying to deploy a simple EKS+Fargate cluster to them ended up missiong permissions failure in
eu-central-1
,ap-southeast-1
andap-southeast-2
.Reproduction Steps
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: