Update: SOLVED, see thread Hi everyone, I'm hav...
# google-cloud
b
Update: SOLVED, see thread Hi everyone, I'm having trouble using pulumi to set up a Private Endpoint Link between MongoDB and Google Cloud. When creating a GCP Forwarding Rule to forward an allocated IP address to the target MongoDB Service Attachment, I get these two errors: First error:
Copy code
* Error creating ForwardingRule: googleapi: Error 400: Invalid value for field 'resource.loadBalancingScheme': 'EXTERNAL'. Invalid field set in Private Service Connect Forwarding Rule. This field should not be set., invalid
That one goes away if I manually set
loadBalancingScheme
to be
''
(see below for code)
Copy code
* Error creating ForwardingRule: googleapi: Error 400: Invalid value for field 'resource.labels': ''. Invalid field set in Private Service Connect Forwarding Rule. This field should not be set., invalid
This one won't go away, even after trying to manually set the
labels
to be
{}
,
null
, and
undefined
. Interestingly, I also get the exact same error when I provide an object with values in it! So it seems that the SDK is sending a request to the GCP API that has the labels set to
''
regardless of user input.
I'm using the typescript SDK,
@pulumi/gcp@7.0.0
and
@pulumi/pulumi@3.92.0
Here's the code I'm running:
Copy code
const mongoEndpoint = new mongodbatlas.PrivateLinkEndpoint(
    'mongoPrivateLinkEndpoint',
    {
      projectId: mongoProject.id,
      providerName: 'GCP',
      region: 'CENTRAL_US',
    },
    { provider: getMongoAtlasProvider() }
  );

  const mongoSubnet = new gcp.compute.Subnetwork('mongo-atlas-subnet', {
    name: `mongo-atlas-subnet-${projectId}`,
    purpose: 'PRIVATE_RFC_1918',
    ipCidrRange: '10.120.0.0/16',
    ipv6AccessType: 'INTERNAL',
    network: appVpcNetwork.selfLink,
    region: location,
  });

  const endpoints: mongodbatlas.types.input.PrivateLinkEndpointServiceEndpoint[] = [];
  // create 50 ips and forwarding rules
  for (let i = 0; i < 50; i++) {
    const ip = new gcp.compute.Address(`mongo-atlas-ip-${i}`, {
      name: `mongo-atlas-ip-${i}`,
      region: location,
      subnetwork: mongoSubnet.selfLink,
      addressType: 'INTERNAL',
    });

    const rule = new gcp.compute.ForwardingRule(`mongo-atlas-${i}`, {
      region: location,
      network: appVpcNetwork.name,
      subnetwork: mongoSubnet.name,
      ipAddress: ip.selfLink,
      target: mongoEndpoint.serviceAttachmentNames[i],
      loadBalancingScheme: '',
    });
    endpoints.push({
      endpointName: rule.name,
      ipAddress: ip.address,
    });
  }

  new mongodbatlas.PrivateLinkEndpointService(
    'mongoPrivateLinkEndpointService',
    {
      projectId: mongoProject.id,
      providerName: 'GCP',
      gcpProjectId: '<my-gcp-project>', // redacted
      endpoints,
      endpointServiceId: mongoSubnet.id,
      privateLinkId: mongoEndpoint.id,
    },
    { provider: getMongoAtlasProvider() }
  );
I had a stack transformation registered in another part of the codebase that was adding labels to this resource.
b
my bad 👀