Using resource's id in other resources


I’m using the TypeScript CDK and trying to do something simple: set up a VPC network in GCP.

const network = new gcp.ComputeNetwork(this, `primary-network`, {
  name: `primary-network`,
  autoCreateSubnetworks: false,
  routingMode: 'REGIONAL',

new gcp.ComputeSubnetwork(this, `private-subnet-${config.region}`, {
  name: `private-subnet-${config.region}`,
  region: config.region,
  ipCidrRange: '',
  privateIpGoogleAccess: true,
  dependsOn: [network],

The problem I have above is that is of type string | undefined and because of that I cannot assign it to the field which expects a type string:

Hey @kaisellgren, thanks for raising this question. This is a known issue and tracked in a Github issue: - It’ll be worked on soon. In the meantime, you could overrule the type information with id!

1 Like