pulumi-gcp: managedZoneId does not match the actual dns managed_zone id.

What happened?

Managing a private DNS zone in GCP with Pulumi, giving access to the zone from other networks in the organization. I can create a new zone, and populate it with networks. But then I can no longer add/remove networks, or delete the zone using Pulumi.

I can still manage the zone using the gcloud cli.

Pulumi will throw this error:

    error: 1 error occurred:
    	* updating urn:pulumi:brinqa-prod::brinqa-net-private::gcp:dns/managedZone:ManagedZone::brinqa-net-private: 1 error occurred:
    	* Error updating ManagedZone "projects/brinqa-prod/managedZones/brinqa-net-private": googleapi: Error 400: The field 'entity.managedZone.id' cannot be modified., immutableField

Expected Behavior

That Pulumi can add/remove networks after initial creation.

Steps to reproduce

Start with something like:

import pulumi
import pulumi_gcp as gcp

private_zone = gcp.dns.ManagedZone("private",
    cloud_logging_config=gcp.dns.ManagedZoneCloudLoggingConfigArgs(
        enable_logging=False,
    ),
    description="private",
    dns_name="example.net.",
    name="private",
    private_visibility_config=gcp.dns.ManagedZonePrivateVisibilityConfigArgs(
        networks=[
            gcp.dns.ManagedZonePrivateVisibilityConfigNetworkArgs(
                network_url="https://www.googleapis.com/compute/v1/projects/project-a/global/networks/project-a-vpc",
            ),
            gcp.dns.ManagedZonePrivateVisibilityConfigNetworkArgs(
                network_url="https://www.googleapis.com/compute/v1/projects/project-b/global/networks/project-b-vpc",
            ),
        ],
    ),
    project="dns-project",
    visibility="private",
    opts=pulumi.ResourceOptions(protect=True))

Then either remove one of the network_urls, or add a third one. You will receive the error above.

Output of pulumi about

(slightly edited to mask urn identifiers)

CLI          
Version      3.58.0
Go Version   go1.20.2
Go Compiler  gc

Plugins
NAME    VERSION
gcp     6.51.0
python  unknown

Host     
OS       ubuntu
Version  20.04
Arch     x86_64

This project is written in python: executable='/usr/bin/python3' version='3.8.10
'

Current Stack: brinqa-prod

TYPE                             URN
pulumi:pulumi:Stack              urn:pulumi:xx-prod::xx-net-private::pulumi:pulumi:Stack::xx-net-private-xxx-prod
pulumi:providers:gcp             urn:pulumi:xx-prod::xxx-net-private::pulumi:providers:gcp::default_6_51_0
gcp:dns/managedZone:ManagedZone  urn:pulumi:xx-prod::xx-net-private::gcp:dns/managedZone:ManagedZone::xx-net-private


Found no pending operations associated with xx-prod

Backend        
Name           cm
URL            gs://xxpulumi-state
User           jnelson
Organizations  

Dependencies:
NAME           VERSION
pip            23.0.1
pkg_resources  0.0.0
pulumi-gcp     6.51.0
setuptools     67.6.0
wheel          0.40.0

Pulumi locates its logs in /tmp by default

Additional context

I’ve traced this down to how ints get cast into scientific notation and back.

From a pulumi up -v=9 --logtostderr run:

I0321 22:26:23.855003 2409260 log.go:75] Marshaling property for RPC[Provider[gcp, 0xc00042fd10].Diff(urn:pulumi:brinqa-prod::brinqa-net-private::gcp:dns/managedZone:ManagedZone::brinqa-net-private,projects/brinqa-prod/managedZones/brinqa-net-private).olds]: managedZoneId={2.9610687372243656e+18}

Note: managedZoneId={2.9610687372243656e+18} Then when it tries to perform the update:

I0321 22:26:41.900974 2409260 log.go:75] Updating ManagedZone "projects/xx-prod/managedZones/xx-net-private": map[string]interface {}{"cloudLoggingConfig":map[string]interface {}{}, "creationTime":"2023-03-21T17:05:13.497Z", "description":"xx-net-private", "dnsName":"xx.net.", "id":2961068737224365600, "name":"xx-net-private", "nameServers":[]interface {}{"ns-gcp-private.googledomains.com."}, "privateVisibilityConfig":map[string]interface {}{"networks":[]interface {}{map[string]interface {}{"networkUrl":"https://www.googleapis.com/compute/v1/projects/xx-cicd/global/networks/cicd-vpc"}, map[string]interface {}{"networkUrl":"https://www.googleapis.com/compute/v1/projects/xx-sales/global/networks/sales-vpc"}, map[string]interface {}{"networkUrl":"https://www.googleapis.com/compute/v1/projects/xx-cs/global/networks/cs-vpc"}, map[string]interface {}{"networkUrl":"https://www.googleapis.com/compute/v1/projects/xx-core/global/networks/core-vpc"}, map[string]interface {}{"networkUrl":"https://www.googleapis.com/compute/v1/projects/xx-trial-pcc/global/networks/pcc-vpc"}, map[string]interface {}{"networkUrl":"https://www.googleapis.com/compute/v1/projects/xx-qa/global/networks/qa-vpc"}}}, "visibility":"private"}

Note: "id":2961068737224365600 which is the expanded form of 2.9610687372243656e+18

My actual zone id is:

$ gcloud dns managed-zones describe xx-net-private --project=xx-prod --format="json(id)"
{
  "id": "2961068737224365485"
}

(also google’s API return this as a string)

Let me know if you need any additional info

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you’ve opened one already).

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 20 (5 by maintainers)

Commits related to this issue

Most upvoted comments

This turned out to be a surprisingly tricky problem to tackle. I’m sorry it took so long. I’m happy to report I have tested a working fix on my computer and I just spun up a PR. We will have a fix out soon.

I would like to send my appreciation for the final resolution of this issue. A small shame it took 14 months, but nevertheless I am glad to see it finally resolved. Our google-native solution is still in place to this day, and working fine.

Gotcha. Well, for the record, my solution was to delete it from the state via pulumi state delete. I’m still managing the record sets, just not the zone.

Sorry for the trouble, everyone. I filed an issue with the relevant library, pulumi/pulumi-terraform-bridge#1342 and will get in touch with the maintainers.

@VenelinMartinov For us, without this issue being fixed we can’t easily change our configuration and deploy, needing to instead always use a workaround (such as manually editing in the WebUI and updating Pulumi). None of the workarounds let us just change a setting and go.

The .get function doesn’t work as all of our domains are managed by Pulumi.

Yeah, thanks for flagging this up! We’ll discuss this internally to see if there are any concerns and prioritise it.

We are facing with that as well. During changing provider version it wants to update DNS without differences inside and can’t because of that error.

UPD. pulumi refresh -t URN helped at least to unblock other updates.

Any progress here? I cannot update the DNS created by Pulumi in GCP due to this issue it makes it a bit unusable. I cannot use replace_on_change as is production and DNSsec is enabled. Any suggestion on what to do is very welcome. I tried to add the right id to Pulumi stack JSON file but it always reverted. Thanks for any idea on how to workaround.