CSUNNY
CSUNNY

Reputation: 454

Get private subnet ids using Pulumi

I am trying to create a new EKS cluster using Pulumi. In one of the steps, I need to use the private subnet ids. When I try to get the ids using VPCID, it gives the error

TSError: ⨯ Unable to compile TypeScript:
index.ts(9,2): error TS2322: Type 'Output<string>' is not assignable to type 'string'.

This is what I am trying to do

import * as pulumi from "@pulumi/pulumi";
import * as awsx from "@pulumi/awsx";
import * as eks from "@pulumi/eks";
import * as k8s from "@pulumi/kubernetes";
import * as aws from "@pulumi/aws";

const vpc = aws.ec2.Vpc.get('ais-name', 'vpc-er33332');
const privateSubnet = aws.ec2.getSubnetIds({
    vpcId: vpc.id,
});

AM I doing this wrong, or is there any other way to do this? Thanks a lot in advance

Upvotes: 2

Views: 1352

Answers (1)

Maciej Raszplewicz
Maciej Raszplewicz

Reputation: 31

You can do it using apply on the vpc.id:

const vpc = aws.ec2.Vpc.get('ais-name', 'vpc-er33332');

const privateSubnet = vpc.id.apply(
    vpcId => aws.ec2.getSubnetIds({
        vpcId: vpcId,
    })
);

Upvotes: 3

Related Questions