Hi guys, has anyone seen this error before when cr...
# getting-started
j
Hi guys, has anyone seen this error before when creating eks cluster?
Copy code
Message_: "Security group(s) [sg-0cb56162e90f5f571] are not in the same VPC as the subnets. Please specify a security group that is associated with the VPC: vpc-0b6bc0745054144c7."
This the python code to create cluster:
Copy code
cluster = eks.Cluster(
    cluster_name,
    version="1.22",

    skip_default_node_group=True,

    vpc_id=vpc.id,
    public_subnet_ids=vpc.public_subnet_ids,
    node_associate_public_ip_address=False,
    private_subnet_ids=vpc.private_subnet_ids,
    cluster_security_group=cluster_sg,

    service_role=cluster_role,
    instance_roles=[node_role],

    create_oidc_provider=True,

    cluster_tags=common_tags
)
I know EKS will create a separate security group for cluster service, but seems it’s using my default VPC instead of the
vpc.id
that I passed.
b
Where's the rest of your code? You're creating your security group in a different vpc
b
Right. It is really an AWS error. Security groups belong to particular VPCs. If you want to attach a SG to an EKS cluster, they must both be in the same VPC.
j
Yeah, @mammoth-electrician-64525 has answered this question, but it turned out to be in incorrect attribute ref of VPC, should be
vpc.vpc_id