Hi there! I’m doing a very basic setup: ```"use s...
# getting-started
f
Hi there! I’m doing a very basic setup:
Copy code
"use strict";
const pulumi = require("@pulumi/pulumi");
const aws = require("@pulumi/aws");
const awsx = require("@pulumi/awsx");
const eks = require("@pulumi/eks");
const k8s = require("@pulumi/kubernetes");

// Function to create an EKS cluster in a given region
function createEksCluster(region) {
    // Set the AWS region for the resources
    const provider = new aws.Provider("aws-provider-${region}", { region });

    // Create a VPC for our cluster
    const vpc = new awsx.ec2.Vpc("test-vpc", {}, { provider: provider, numberOfAvailabilityZones: 1 } );

    // Create an EKS cluster
    const cluster = new eks.Cluster("test", {
        vpcId: vpc.id,
        subnetIds: vpc.publicSubnetIds,
        instanceType: "t2.medium",
        desiredCapacity: 1,
        minSize: 1,
        maxSize: 2,
    }, {}, { provider });

    return cluster;
}

function createStatefulSet(cluster) {
    const name = "test-ss";
    const statefulSet = new k8s.apps.v1.StatefulSet(name, {
        metadata: { name: name },
        spec: {
            serviceName: name,
            replicas: 1,
            selector: { matchLabels: { app: name } },
            template: {
                metadata: { labels: { app: name } },
                spec: {
                    containers: [{
                        name: name,
                        image: "nginx", // As an example, replace with required image
                    }],
                },
            },
        },
    }, { provider: cluster.provider });
    return statefulSet;
}


// Create EKS clusters in the desired regions
// const clusterUSEast1 = createEksCluster("us-east-1");
const clusterFrankfurt = createEksCluster("eu-central-1");
createStatefulSet(clusterFrankfurt);

// Export the kubeconfig for each cluster
// exports.kubeconfigUSEast1 = clusterUSEast1.kubeconfig;
exports.kubeconfigFrankfurt = clusterFrankfurt.kubeconfig;
However when deployed i get the error that the error InvalidParameterException: The subnet ID ‘subnet-__________’ does not exist. I can clearly see the subnet when i look in the aws console so im not sure whats going on (and its being created by my code)
d
It looks like you've passed too many objects to the Cluster resource, so it won't be using the correct provider
f
Is the provider supposed to be the second object?
d
Yes
f
Oddly then i get the error:
Copy code
failed with an unhandled exception:
    Error: It looks like you're using an explicit AWS provider. Please specify this provider in providerCredentialOpts.
Copy code
// Create an EKS cluster
    const cluster = new eks.Cluster("test", {
        vpcId: vpc.id,
        subnetIds: vpc.publicSubnetIds,
        instanceType: "t2.medium",
        desiredCapacity: 1,
        minSize: 1,
        maxSize: 2,
    }, { provider });
https://github.com/pulumi/pulumi-eks/blob/master/nodejs/eks/cluster.ts#L1707 which i guess happens if you pass it as the third arg
(Also thank you so much for your help! im new and have been banging on this all day)
d
https://www.pulumi.com/registry/packages/eks/api-docs/cluster/#providercredentialopts_nodejs I'm not that familiar with EKS auth, but hope you can work it out now you're unblocked
f
Ahh so its some sort of auth issue! Thank you!