hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.11k forks source link

[Bug]: TLD .co.uk contact changes fail, CONTACT_TYPE missing #35597

Closed sjackson0109 closed 6 months ago

sjackson0109 commented 8 months ago

Terraform Core Version

1.6.6

AWS Provider Version

5.34.0

Affected Resource(s)

aws_route53_domains_registered_domain

Expected Behavior

When trying to mass-update 50+ domains, only the .co.uk domains failed with an error. They should update, just-the-same way as all the others (.com, .uk, .net, .international, .io).

Actual Behavior

│ Error: updating Route 53 Domains Domain (mydomain.co.uk) contacts: operation error Route 53 Domains: UpdateDomainContact, https response error StatusCode: 400, RequestID: f5205004-66ec-4cf2-9f39-e473306a1b5a, TLDRulesViolation: [ADMIN.UK_CONTACT_TYPE is missing, OWNER.UK_CONTACT_TYPE is missing, TECH.UK_CONTACT_TYPE is missing, BILL.UK_CONTACT_TYPE is missing]
│
│   with aws_route53domains_registered_domain.this["mydomain.co.uk"],
│   on main.tf line 17, in resource "aws_route53domains_registered_domain" "this":
│   17: resource "aws_route53domains_registered_domain" "this" {
│
╵

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

TF

https://github.com/sjackson0109/tf-aws-route53-domains

TFVARS

contacts = {
  0 = {
    address_line_1 = "Buckingham Palace"         # (Optional) First line of the contact's address.
    address_line_2 = null                        # (Optional) Second line of contact's address if any.
    city           = "London"                    # (Optional) The city of the contact's address.
    contact_type   = "COMPANY"                   # (Optional) Indicates whether the contact is a person company association or public organization.
    #                                            Options: PERSON | COMPANY | ASSOCIATION | PUBLIC_BODY | RESELLER
    #                                            More reading: https://docs.aws.amazon.com/cli/latest/reference/route53domains/update-domain-contact.html
    country_code      = "GB"                     # (Optional) Code for the country of the contact's address. See the AWS API documentation for valid values.
    email             = "whois@mytestdomain.com" # (Optional) Email address of the contact.
    extra_params      = null                     # (Optional) A key-value map of parameters required by certain top-level domains.
    fax               = null                     # (Optional) Fax number of the contact. Phone number must be specified in the format "+[country dialing code].[number including any area code]".
    first_name        = "His Majesty"            # (Optional) First name of contact.
    last_name         = "The King"               # (Optional) Last name of contact.
    organization_name = "My Test Domain Company" # (Optional) Name of the organization for contact types other than PERSON.
    phone_number      = "+44.0000000000"         # (Optional) The phone number of the contact. Phone number must be specified in the format "+[country dialing code].[number including any area code]".
    state             = null                     # (Optional) The state or province of the contact's city.
    zip_code          = "SW1A 1AA"               # (Optional) The zip or postal code of the contact's address.
  },
  1 = {
    address_line_1    = "Buckingham Palace"      # (Optional) First line of the contact's address.
    address_line_2    = null                     # (Optional) Second line of contact's address if any.
    city              = "London"                 # (Optional) The city of the contact's address.
    contact_type      = "PERSON"                 # (Optional) Indicates whether the contact is a person company association or public organization.
    country_code      = "GB"                     # (Optional) Code for the country of the contact's address. See the AWS API documentation for valid values.
    email             = "whois@mytestdomain.com" # (Optional) Email address of the contact.
    extra_params      = null                     # (Optional) A key-value map of parameters required by certain top-level domains.
    fax               = null                     # (Optional) Fax number of the contact. Phone number must be specified in the format "+[country dialing code].[number including any area code]".
    first_name        = "King"                   # (Optional) First name of contact.
    last_name         = "Charles III"            # (Optional) Last name of contact.
    organization_name = "My Test Domain Company" # (Optional) Name of the organization for contact types other than PERSON.
    phone_number      = "+44.0000000000"         # (Optional) The phone number of the contact. Phone number must be specified in the format "+[country dialing code].[number including any area code]".
    state             = null                     # (Optional) The state or province of the contact's city.
    zip_code          = "SW1A 1AA"               # (Optional) The zip or postal code of the contact's address.
  }
}

domains = {
  "mydomain.co.uk" = {
    registrar     = "route53"
    auto_renew    = true
    transfer_lock = true
    contacts = {
      registrant_key = "0"
      admin_key      = "1"
      tech_key       = "1"
    }
  },
 "mydomain.com" = {
    registrar     = "route53"
    auto_renew    = true
    transfer_lock = true
    contacts = {
      registrant_key = "0"
      admin_key      = "1"
      tech_key       = "1"
    },
 "mydomain.net" = {
    registrar     = "route53"
    auto_renew    = true
    transfer_lock = true
    contacts = {
      registrant_key = "0"
      admin_key      = "1"
      tech_key       = "1"
    }
  }
}

Steps to Reproduce

terraform plan 2 changes

terraform apply -auto-approve 1 success, 1 failed

And yes i did all the email-verification stages.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 8 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

sjackson0109 commented 8 months ago

Looks like the specific TLD requirements are violated...

TLDRulesViolation: [ADMIN.UK_CONTACT_TYPE is missing, OWNER.UK_CONTACT_TYPE is missing, TECH.UK_CONTACT_TYPE is missing, BILL.UK_CONTACT_TYPE is missing]

Thats 4x contact objects required:

And the terraform registry, for this provider module, this resource, and matching this version, shows only 3x supported blocks:

[Contact Blocks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53domains_registered_domain#contact-blocks)
The admin_contact, registrant_contact and tech_contact blocks support the following:
..... following lines snipped....

Guess we need a different billing contact, and a comment to clarify owner=registrant.

sjackson0109 commented 8 months ago

Tring to fix this manually, looks like the TLD for .co.uk also asks for additional payload of the registrant contact details too... image

sjackson0109 commented 7 months ago

This may simply have been me not being aware of the additional payloads needed

revised...

  contacts = {
   0 = {
    # many rows redacted
    extra_params      = {
      UK_COMPANY_NUMBER = "00000000"       # Matches UK Company Register (Companies House)
      UK_CONTACT_TYPE = "PLC"
    }
   }
  }

inside my contacts_blocks, i added a simple check for the TLD, .co.uk:

    extra_params      = substr(each.key,length(each.key)-6,6) == ".co.uk" ? try(var.contacts[each.value.contacts.registrant_key].extra_params, null) : null
sjackson0109 commented 7 months ago

Am afraid, same issue, even with the extra params populated correctly:

2024-02-03T15:00:40.887Z [DEBUG] provider.terraform-provider-aws_v5.34.0_x5.exe: HTTP Response Received: tf_provider_addr=registry.terraform.io/hashicorp/aws @module=aws http.response.header.x_amzn_requestid=e55d063b-212e-403a-b20b-db07ab2a153a rpc.system=aws-api tf_aws.signing_region="" tf_resource_type=aws_route53domains_registered_domain @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.46/logging/tf_logger.go:45 http.response.header.content_type=application/x-amz-json-1.1 rpc.service="Route 53 Domains" tf_aws.sdk=aws-sdk-go-v2 aws.region=us-east-1 http.response.header.date="Sat, 03 Feb 2024 15:00:22 GMT" rpc.method=UpdateDomainContact
justinretzolk commented 6 months ago

Hey @sjackson0109 👋 Thank you for taking the time to raise this! In triaging this, I happened upon the same extra_params find that you did. If you haven't already, it might be worth using something like terraform console to validate that the chain of functions you're using to populate extra_params is evaluating as you're expecting it to.

If you're still having issues after that, are you able to provide debug logs (redacted as necessary) in case whoever picks this up needs that information?

sjackson0109 commented 6 months ago

Hi @justinretzolk - Thanks for the feedback, yes i managed to solve it using the extra_params, on my test domain. yet to push it to the customer who needed this work a month or two ago. Shame it wasn't so obvious from the tf registry documentation.

github-actions[bot] commented 5 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.