Quantcast
Channel: Terraform - HashiCorp Discuss
Viewing all articles
Browse latest Browse all 11361

Using resource's id in other resources

$
0
0

Hi.

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: '10.0.0.0/8',
  privateIpGoogleAccess: true,
  network: network.id,
  dependsOn: [network],
})

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

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 11361

Trending Articles