import * as awsinfra from "@pulumi/aws-infra" ; import * as eks from "@pulumi/eks" ; import * as pulumi from "@pulumi/pulumi" ; import * as config from "./config" ; let vpcId = config . vpcId ! ; let publicSubnetIds = config . publicSubnetIds ! ; let privateSubnetIds = config . privateSubnetIds ! ; if ( config . vpcId === undefined ) { const network = new awsinfra . Network ( "network" , { usePrivateSubnets : config . usePrivateSubnets , numberOfAvailabilityZones : config . numberOfAvailabilityZones , } ) ; vpcId = network . vpcId ; publicSubnetIds = network . publicSubnetIds ; privateSubnetIds = config . usePrivateSubnets ? network . subnetIds : undefined ; } const identityStack = new pulumi . StackReference ( "identityStack" , { name : config . identityStack } ) ; const kubeAppRole = identityStack . getOutput ( "kubeAppRoleArn" ) ; kubeAppRole . apply ( role => { if ( role === undefined ) { throw Error ( `Stack output ${ identityStack }.kubeAppRoleArn is undefined` ) ; } } ) ; const eksCluster = new eks . Cluster ( "eksCluster" , { vpcId : vpcId , subnetIds : [ ... publicSubnetIds , ... ( privateSubnetIds || [ ] ) ] , roleMappings : [ { roleArn : kubeAppRole , username : kubeAppRole , groups : [ "system:masters" ] , } , ] , instanceType : < any > config . instanceType , nodePublicKey : config . publicKey , desiredCapacity : config . desiredCapacity , minSize : config . minSize , maxSize : config . maxSize , storageClasses : config . storageClass , } ) ; export const kubeconfig = eksCluster . kubeconfig ;