Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to apply google_dns_managed_zone #17682

Open
fawaf opened this issue Mar 25, 2024 · 5 comments
Open

failed to apply google_dns_managed_zone #17682

fawaf opened this issue Mar 25, 2024 · 5 comments

Comments

@fawaf
Copy link

fawaf commented Mar 25, 2024

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version

Terraform v1.7.5
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.21.0

Affected Resource(s)

google_dns_managed_zone

Terraform Configuration

#tfsec:ignore:google-dns-enable-dnssec
resource "google_dns_managed_zone" "dns_managed_zone" {
  project     = "blah"
  name        = "foo-com
  dns_name    = "foo.com."
  description = "Managed by Terraform"
  labels      = {}

  visibility = "public"

  dynamic "private_visibility_config" {
    for_each = "public" == "public" ? toset([]) : toset([1])

    content {
      networks {
        network_url = data.google_compute_network.main_vpc.self_link
      }
    }
  }
}

Debug Output

https://gist.github.com/fawaf/38d1633ef38e8a37867a24cedd054190

Expected Behavior

tf should have applied successfully if the zone already exists previously

Actual Behavior

error produced:

Error: Error updating ManagedZone "projects/blah/managedZones/foo" googleapi: Error 400: The 'entity.managedZone.dnssecConfig' parameter is required but was missing., required

Steps to reproduce

  1. zone already exists in gcp project
  2. terraform apply

Important Factoids

No response

References

No response

b/332515087

@fawaf fawaf added the bug label Mar 25, 2024
@github-actions github-actions bot added forward/review In review; remove label to forward service/cloud-dns labels Mar 25, 2024
@ggtisc ggtisc self-assigned this Mar 26, 2024
@ggtisc
Copy link
Collaborator

ggtisc commented Mar 26, 2024

Hi @fawaf could you be more specific on what are you trying to update or it can be any property like the description? For example:

Initial value:
description = "Managed by Terraform"

Updated value:
description = "Managed by Terraform 2.0"

@fawaf
Copy link
Author

fawaf commented Mar 26, 2024

ahh for sure. I'm not updating anything. it works on initial creation and then immediately fails the second time the apply is run. the plan shows tf tries to remove the dnssec config.

orm used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_dns_managed_zone.dns_managed_zone will be updated in-place
  ~ resource "google_dns_managed_zone" "dns_managed_zone" {
        id               = "projects/blah/managedZones/blah"
        name             = "blah"
        # (11 unchanged attributes hidden)

      - dnssec_config {
          - kind          = "dns#managedZoneDnsSecConfig" -> null
          - non_existence = "nsec3" -> null
          - state         = "off" -> null

          - default_key_specs {
              - algorithm  = "rsasha256" -> null
              - key_length = 2048 -> null
              - key_type   = "keySigning" -> null
              - kind       = "dns#dnsKeySpec" -> null
            }
          - default_key_specs {
              - algorithm  = "rsasha256" -> null
              - key_length = 1024 -> null
              - key_type   = "zoneSigning" -> null
              - kind       = "dns#dnsKeySpec" -> null
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to per

@roaks3 roaks3 assigned roaks3 and unassigned ggtisc Mar 28, 2024
@roaks3
Copy link
Collaborator

roaks3 commented Mar 28, 2024

I was not able to reproduce the issue following your steps. I noticed that the GET /dns/v1/projects/... API call for me did not return a dnssecConfig field (as expected), but your API call did return a dnssecConfig field, and is responsible for the diff you're seeing.

Is there any chance this managed zone was modified outside of Terraform (like through the console or gcloud)?

@fawaf
Copy link
Author

fawaf commented Mar 29, 2024

i tested it on both types of zones that you mentioned. modifying outside of tf causes the error, and directly creating with tf and not touching it afterwards also produces the same error. i'll double check again if there's something funky going on.

@roaks3
Copy link
Collaborator

roaks3 commented Apr 2, 2024

I looked into this a bit more (reading our docs and some internal source), and it looks to me like there are ways for DNSSEC to be configured elsewhere that could be applied to a newly created zone, even when a dnssec_config is not explicitly specified. However, I'm not an expert on these features, so I'm going to forward to the service team to have a look.

If this is a default that is applied to the zone on the backend, I believe we would need to add a default_from_api: true line to this field to avoid this diff.

@roaks3 roaks3 removed the forward/review In review; remove label to forward label Apr 2, 2024
@roaks3 roaks3 removed their assignment May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants