able-camera-57198
11/05/2021, 1:22 PMvar computeService = new Service(
"compute",
options: new() {
Parent = this,
},
args: new ServiceArgs
{
ServiceName = "<http://compute.googleapis.com|compute.googleapis.com>",
}
);
var defaultNetwork = Output.Create(GetNetwork.InvokeAsync(new()
{
Network = "default",
}));
Is there any way for me to have the call to GetNetwork
depend on computeService
? Right now GCP is giving me an error because I'm trying to call GetNetwork
prior to the API for it being enabled...prehistoric-activity-61023
11/05/2021, 1:38 PMGetNetwork
come from?able-camera-57198
11/05/2021, 1:38 PMprehistoric-activity-61023
11/05/2021, 1:39 PMable-camera-57198
11/05/2021, 1:39 PMprehistoric-activity-61023
11/05/2021, 1:39 PMget
function has opts
where you should be able to set dependsOn
able-camera-57198
11/05/2021, 1:39 PMprehistoric-activity-61023
11/05/2021, 1:40 PMdependsOn
while getting existing resources but I do use that while creating some of themable-camera-57198
11/05/2021, 1:41 PMprehistoric-activity-61023
11/05/2021, 1:42 PMget
behavior is no different than the one implemented while creating new resources that should do the trick. If no, I guess it’d be worth reporting this as a bug.able-camera-57198
11/05/2021, 1:42 PMdependsOn
isn't an option there either.prehistoric-activity-61023
11/05/2021, 1:43 PMable-camera-57198
11/05/2021, 1:43 PMprehistoric-activity-61023
11/05/2021, 1:48 PMable-camera-57198
11/05/2021, 1:48 PMPulumi.Gcp.Compute
. That's the classic provider.prehistoric-activity-61023
11/05/2021, 1:49 PMpublic static Network Get(string name, Input<string> id, NetworkState? state, CustomResourceOptions? opts = null)
able-camera-57198
11/05/2021, 1:49 PMprehistoric-activity-61023
11/05/2021, 1:49 PMCustomResourceOptions
seems to have `DependsOn`:
https://www.pulumi.com/docs/reference/pkg/dotnet/Pulumi/Pulumi.CustomResourceOptions.htmlable-camera-57198
11/05/2021, 1:49 PMGetNetwork
functionprehistoric-activity-61023
11/05/2021, 1:50 PMable-camera-57198
11/05/2021, 1:50 PMprehistoric-activity-61023
11/05/2021, 1:51 PMable-camera-57198
11/05/2021, 1:51 PMprehistoric-activity-61023
11/05/2021, 1:52 PMable-camera-57198
11/05/2021, 1:52 PMprehistoric-activity-61023
11/05/2021, 1:52 PMpulumi up/preview
and you’re gonna get full-fledged pulumi resource of the given typeable-camera-57198
11/05/2021, 1:54 PMGet
is a method on the type?prehistoric-activity-61023
11/05/2021, 1:54 PMable-camera-57198
11/05/2021, 1:54 PMprehistoric-activity-61023
11/05/2021, 1:55 PMNetwork
within Pulumi.Gcp.Compute
and see whether it has a static method called Get
able-camera-57198
11/05/2021, 1:55 PMprehistoric-activity-61023
11/05/2021, 1:57 PMable-camera-57198
11/05/2021, 1:58 PMprehistoric-activity-61023
11/05/2021, 2:03 PMable-camera-57198
11/05/2021, 2:04 PMprehistoric-activity-61023
11/05/2021, 2:05 PMable-camera-57198
11/05/2021, 2:05 PMError 403: Compute Engine API has not been used in project ########### before or it is disabled.
DependsOn
.prehistoric-activity-61023
11/05/2021, 2:08 PMdependsOn
attribute” or sth like thatable-camera-57198
11/05/2021, 2:12 PMprehistoric-activity-61023
11/05/2021, 2:12 PMable-camera-57198
11/05/2021, 2:13 PMprehistoric-activity-61023
11/05/2021, 2:14 PMget
functions might be tricky. They (most probably) are evaluated during plan phase because other changes might depend on it. If you want it to depend on some resource creation, we have chicked-and-egg problem.able-camera-57198
11/05/2021, 2:16 PMprehistoric-activity-61023
11/05/2021, 2:18 PMable-camera-57198
11/05/2021, 2:19 PMprehistoric-activity-61023
11/05/2021, 2:19 PMable-camera-57198
11/05/2021, 2:20 PMprehistoric-activity-61023
11/05/2021, 2:21 PMable-camera-57198
11/05/2021, 2:21 PM"default"
network that GCP creates for all projects once compute is enabled.prehistoric-activity-61023
11/05/2021, 2:22 PMable-camera-57198
11/05/2021, 2:23 PMprehistoric-activity-61023
11/05/2021, 2:25 PMdef __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
auto_create_subnetworks: Optional[pulumi.Input[bool]] = None,
delete_default_routes_on_create: Optional[pulumi.Input[bool]] = None,
description: Optional[pulumi.Input[str]] = None,
mtu: Optional[pulumi.Input[int]] = None,
name: Optional[pulumi.Input[str]] = None,
project: Optional[pulumi.Input[str]] = None,
routing_mode: Optional[pulumi.Input[str]] = None,
__props__=None):
auto_create_network=false
• you create a vpc with most of the default values (so you don’t need to create subnetwork manually if you don’t want to)
• you have a managed vpc network (so no problems with getting it)able-camera-57198
11/05/2021, 2:29 PMprehistoric-activity-61023
11/05/2021, 2:31 PMable-camera-57198
11/05/2021, 2:32 PMprehistoric-activity-61023
11/05/2021, 2:33 PM#
# Configure NAT router
#
self.router = gcp.compute.Router(
name,
network=self.network.name,
project=project,
region=region,
opts=ResourceOptions(parent=self.network),
)
self.nat = gcp.compute.RouterNat(
name,
router=self.router.name,
nat_ip_allocate_option="AUTO_ONLY",
source_subnetwork_ip_ranges_to_nat="ALL_SUBNETWORKS_ALL_IP_RANGES",
log_config=gcp.compute.RouterNatLogConfigArgs(
enable=True, filter="ERRORS_ONLY"
),
project=project,
region=region,
opts=ResourceOptions(parent=self.network),
)
#
# Create private VPC peering connection
#
# Some Google managed services (such as Cloud SQL) require private services access for each VPC network
# that is used for private IP connections. This is a one-time procedure but it must be performed before
# attempting to create dependent services.
#
# See: <https://cloud.google.com/sql/docs/mysql/configure-private-services-access>
#
ip_address_range = gcp.compute.GlobalAddress(
self._name,
purpose="VPC_PEERING",
address_type="INTERNAL",
prefix_length=16,
network=self.network.name,
project=project,
opts=ResourceOptions(parent=self.network),
)
self.private_connection = gcp.servicenetworking.Connection(
self._name,
network=self.network.id,
service="<http://servicenetworking.googleapis.com|servicenetworking.googleapis.com>",
reserved_peering_ranges=[ip_address_range.name],
opts=ResourceOptions(parent=self.network),
)
able-camera-57198
11/05/2021, 2:34 PM.tf
which I'm going to be transposing over.prehistoric-activity-61023
11/05/2021, 2:35 PMable-camera-57198
11/05/2021, 2:35 PMprehistoric-activity-61023
11/05/2021, 2:36 PMable-camera-57198
11/05/2021, 2:36 PM.tf
templates to be less monolith-y, so moving to Pulumi seemed like a smart move.prehistoric-activity-61023
11/05/2021, 2:37 PMable-camera-57198
11/05/2021, 2:37 PMprehistoric-activity-61023
11/05/2021, 2:37 PMable-camera-57198
11/05/2021, 2:37 PMprehistoric-activity-61023
11/05/2021, 2:38 PMable-camera-57198
11/05/2021, 2:38 PMprehistoric-activity-61023
11/05/2021, 2:38 PMable-camera-57198
11/05/2021, 2:40 PMprehistoric-activity-61023
11/05/2021, 2:40 PMable-camera-57198
11/05/2021, 2:42 PMprehistoric-activity-61023
11/05/2021, 2:43 PMable-camera-57198
11/05/2021, 2:43 PMprehistoric-activity-61023
11/05/2021, 2:43 PMable-camera-57198
11/05/2021, 2:44 PMprehistoric-activity-61023
11/05/2021, 2:44 PMable-camera-57198
11/05/2021, 2:45 PM