https://pulumi.com logo
#getting-started
Title
# getting-started
j

jolly-plumber-1488

07/11/2022, 11:13 AM
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

billowy-army-68599

07/11/2022, 12:28 PM
Where's the rest of your code? You're creating your security group in a different vpc
b

better-umbrella-26052

07/11/2022, 1:19 PM
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

jolly-plumber-1488

07/11/2022, 9:23 PM
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
9 Views