I'm trying to figure out why I keep getting a Pulu...
# general
m
I'm trying to figure out why I keep getting a Pulumi error
TypeError: Cannot read property 'kubeconfig' of undefined
. The documentation and code examples suggests I should have access to the kubeconfig and provider from the output. Can I get someone to take a look at see if I just missed something here? Much appreciated.
Copy code
// Create method in EKS class
async createEksCluster (networking) {
  try {
    const cluster = new eks.Cluster(this.clusterName, {
      endpointPrivateAccess: this.apiPrivateAccess,
      endpointPublicAccess: this.apiPublicAccess,
      skipDefaultNodeGroup: true,
      version: this.version,
      vpcId: networking.apply(network => network.vpcId),
      subnets: networking.apply(network => network.publicSubnetIds),
      nodeAssociatePublicIpAddress: false,
      deployDashboard: false,
      tags: {
        stack: this.stack
      }
    })
    return cluster
  } catch (error) {
    Error(error)
  }
}

// Calling function
const cluster = await eks.createEksCluster(networking)

// Combining output into usable inputs for other modules
const composite = pulumi.all([
  cluster.kubeconfig,
  cluster.provider,
  cluster.core.instanceProfile
]).apply(([
  kubeconfig,
  provider,
  instanceProfile
]) => {
  return {
    kubeconfig: kubeconfig,
    provider: provider,
    instanceProfile: instanceProfile
  }
})
b
the whole return value of createEksCluster is undefined, not just the kubeconfig
if you remove the try-catch you should see the error you get. as is you're just catching the error without logging it and implicitly returning undefined from the function
m
Makes sense. I can remove the
try catch
locally and still don't get any errors. CI, however, gets that error all the time
w
I'm not sure I understand what the goal of all the
async/await
here is. But indeed since you are catching the error and not returning anything in the
catch
clause - this function will return
undefined
if there is an error. You could rethrow it, or
console.log
it, to see what the error is? (or could just remove all the `async`/`await` here - which I don't think is actually doing anything?)
m
Thank you both for the responses. I'm pretty sure I found the issue.
🎉 1