ovh / terraform-provider-ovh

Terraform OVH provider
https://registry.terraform.io/providers/ovh/ovh/latest/docs
Mozilla Public License 2.0
183 stars 135 forks source link

[DOCS] The docs for 'ovh_domain_zone' do not mention what "configuration templates" are #505

Closed tonejito closed 9 months ago

tonejito commented 9 months ago

Documentation link

Please provide a link to the affected page on the Terraform Registry.

Description

Please explain the problem in the documentation page and what should be the expected behavior.

The ovh_domain_zone resource has a field named configuration. The docs page says the following:

configuration - (Optional) Representation of a configuration item for personalizing product

The code example looks like this, but the documentation does not mention what does configuration stands for, or the available template names to use.

resource "ovh_domain_zone" "zone" {

    ...

    configuration {
      label = "template"
      value = "minimized"
    }
  }
}

I created an ovh_domain_zone resource and I got a bunch of DNS records bundled in without declaration.

$TTL 3600
@       IN SOA dns10.ovh.ca. tech.ovh.net. (2023113003 86400 3600 3600000 60)
           IN NS     dns10.ovh.ca.
           IN NS     ns10.ovh.ca.
           IN A      144.217.153.176
           IN TXT    "1|www.terraform.example.com"
       600 IN TXT    "v=spf1 include:mx.ovh.ca ~all"
www        IN A      144.217.153.176
www        IN TXT    "3|welcome"

I assume those records are part of the template, but I could not find their definition in the docs or API.

tonejito commented 9 months ago

I tried to create a new zone without specifying the template and I got a 400 error. So I believe the configuration => template attribute is required, not optional.

This is the content of my main.tf file where I commented the configuration template attribute:

terraform {
  required_providers {
    ovh = {
      source = "ovh/ovh"
    }
  }
}

provider "ovh" {
  endpoint           = "ovh-ca"
  application_key    = "xxxxxxxxxxxxxxxx"
  application_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  consumer_key       = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

data "ovh_me" "myaccount" {}

data "ovh_order_cart" "mycart" {
  ovh_subsidiary = data.ovh_me.myaccount.ovh_subsidiary
}

data "ovh_order_cart_product_plan" "zone" {
  cart_id        = data.ovh_order_cart.mycart.id
  price_capacity = "renew"
  product        = "dns"
  plan_code      = "zone"
}

resource "ovh_domain_zone" "domain_zone" {
  ovh_subsidiary = data.ovh_order_cart.mycart.ovh_subsidiary

  plan {
    plan_code    = data.ovh_order_cart_product_plan.zone.plan_code
    duration     = data.ovh_order_cart_product_plan.zone.selected_price.0.duration
    pricing_mode = data.ovh_order_cart_product_plan.zone.selected_price.0.pricing_mode

    configuration {
      label = "zone"
      value = "zone.example.com"
    }

    # configuration {
    #   label = "template"
    #   value = "minimized"
    # }
  }
}

This is the output of my failed terraform apply attempt:

% terraform apply
data.ovh_me.myaccount: Reading...
data.ovh_me.myaccount: Read complete after 0s [id=somebody@example.com]
data.ovh_order_cart.mycart: Reading...
data.ovh_order_cart.mycart: Read complete after 0s [id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]
data.ovh_order_cart_product_plan.zone: Reading...
data.ovh_order_cart_product_plan.zone: Read complete after 1s [id=zone]

Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following
symbols:
  + create

Terraform will perform the following actions:

  # ovh_domain_zone.domain_zone will be created
  + resource "ovh_domain_zone" "domain_zone" {
      + dnssec_supported = (known after apply)
      + has_dns_anycast  = (known after apply)
      + id               = (known after apply)
      + last_update      = (known after apply)
      + name             = (known after apply)
      + name_servers     = (known after apply)
      + order            = (known after apply)
      + ovh_subsidiary   = "WE"
      + urn              = (known after apply)

      + plan {
          + duration     = "P1Y"
          + plan_code    = "zone"
          + pricing_mode = "default"

          + configuration {
              + label = "zone"
              + value = "zone.example.com"
            }
        }
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

ovh_domain_zone.domain_zone: Creating...
╷
│ Error: Could not order domain zone: "calling Post /order/cart/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/checkout:
│ "OVHcloud API error (status code 400): Client::BadRequest: "template not found"
│ (X-OVH-Query-Id: CA.ext-a.bbbbbbbb.ccccc.dddddddddddddddddddddddddddddddd)""
│
│   with ovh_domain_zone.domain_zone,
│   on main.tf line 29, in resource "ovh_domain_zone" "domain_zone":
│   29: resource "ovh_domain_zone" "domain_zone" {
│
tonejito commented 9 months ago

XREF from #511