https://pulumi.com logo
Title
p

prehistoric-toddler-40668

11/13/2022, 11:49 AM
Hey everyone! I’m kinda new to typescript and deploying a pulumi program that creates a vpc and then needs to assign the subnet id’s to an EKS cluster. i built a class that creates a vpc, and returns a promise of the subnet id’s. i want to reference the subnet id in another class that creates an eks cluster. but i cant figure out how to resolve the promise, help would be very appreciated 🙂 this is the vpc configuration. inside a module called vpc:
import { ec2 } from  "@pulumi/awsx";
 class Vpc{
     vpc = new ec2.Vpc("ververica-vpc", {
        cidrBlock: "172.17.0.0/16",
        numberOfAvailabilityZones: 2,
        subnets: [
            { type: "public" }, { type: "private" }
             ],
         }
    );
}

export const ververica_vpc = new Vpc();
eks:
export class EKS{
        eks_role = new aws.iam.Role("eks-iam-role", {
             assumeRolePolicy: JSON.stringify({
                 Version: "2012-10-17",
                 Statement: [{
                     Action: "sts:AssumeRole",
                     Effect: "Allow",
                     Sid: "",
                     Principal: {
                         Service: "<http://ec2.amazonaws.com|ec2.amazonaws.com>",
                     },
                 }],
             }),
             managedPolicyArns: [
                 'arn:aws:iam::aws:policy/AmazonEKSServicePolicy',
                 'arn:aws:iam::aws:policy/AmazonEKSClusterPolicy'
             ]
           }
         );
        ververica_eks = new aws.eks.Cluster("ververica_cluster", {
             roleArn: this.eks_role.arn,
             vpcConfig: {
                 subnetIds: [
                    vpc.ververica_vpc.vpc.privateSubnetIds.then((id) => 
                    )
                                 ],
             },
         }
        );
    }
SubnetIds in the EKS Configuration is the issue 🙂
v

victorious-church-57397

11/13/2022, 1:56 PM
You can use .apply() to resolve the promises. You probably want to extend the pulumi custom resource class for your custom classes too
p

prehistoric-toddler-40668

11/14/2022, 10:46 AM
Thank you very much!!! @victorious-church-57397
v

victorious-church-57397

11/14/2022, 10:52 AM
No probs mate :)