https://pulumi.com logo
b

best-summer-38252

02/09/2020, 6:01 AM
anyone with an example of looking up the default network for a project ?
m

mammoth-elephant-55302

02/09/2020, 6:13 AM
b

best-summer-38252

02/09/2020, 6:23 AM
hey Jacob, not sure. Im trying to a project's vpc to use elsewhere
m

mammoth-elephant-55302

02/09/2020, 7:33 AM
hopefully someone with more experience can help. I think when you create the first VPC you can reference it using the variable... but if it's not created in Pulumi I wonder how you can get that information 🤔 it looks like there are some differences between the API and some options available on Cloud Console: https://github.com/pulumi/pulumi-gcp/issues/133 maybe another idea is to delete the auto-created network:
gcp.organizations.Project ~> autoCreateNetwork: false
it will temporarily create a network then delete it right after the project is created...
Copy code
import * as gcp from "@pulumi/gcp";

const peeringNetwork = new gcp.compute.Network("peeringNetwork", {});
const privateIpAlloc = new gcp.compute.GlobalAddress("privateIpAlloc", {
     addressType: "INTERNAL",
     network: peeringNetwork.selfLink,
     prefixLength: 16,
     purpose: "VPC_PEERING",
});
const foobar = new gcp.servicenetworking.Connection("foobar", {
     network: peeringNetwork.selfLink,
     reservedPeeringRanges: [privateIpAlloc.name],
     service: "<http://servicenetworking.googleapis.com|servicenetworking.googleapis.com>",
});
g

gentle-diamond-70147

02/10/2020, 2:29 PM
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/gcp/compute/#getNetwork should work for you using “default” as the name to lookup.
❤️ 1
b

best-summer-38252

02/10/2020, 5:20 PM
Thank you @mammoth-elephant-55302 & @gentle-diamond-70147 I was making it more difficult than necessary - this simplified it a bunch :D
👍 1