akamai / terraform-provider-akamai

Terraform Akamai provider
https://www.terraform.io/docs/providers/akamai/
Mozilla Public License 2.0
110 stars 99 forks source link

Issue with multi-line TXT records #25

Closed bogdan-grozoiu closed 4 years ago

bogdan-grozoiu commented 5 years ago

Terraform Version

Terraform v0.12.5 Akamai Provider v0.1.1

Affected Resource(s)

Terraform Configuration Files

terraform {
  required_version = ">= 0.12"
}

# Initialize the Akamai provider
provider "akamai" {
  version = "0.1.1"
  edgerc = "~/.edgerc"
  dns_section = "default"
}

resource "akamai_dns_record" "acc_companydomain_com-txt" {
  zone       = var.zone
  name       = "acc.companydomain.com"
  recordtype = "TXT"
  ttl        = var.default_ttl
  active     = true
  target = [
    "OneWord",
    "Two Words"
    ]
}

Expected Behavior

Terraform using the Akamai provider to provision a TXT record with 2 lines of text, each line containing only what is between the double quotes. E.g.:

Actual Behavior

A TXT record is created / updated but the 2 lines look like following:

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform init
    
    Initializing the backend...

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.

If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.

2. `terraform plan`

Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage.

akamai_dns_record.acc_companydomain_com-txt: Refreshing state... [id=acc.companydomain.com-acc.companydomain.com-TXT-c007526e74222c0861d69a9e9fd662ff7048459a]


An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols: ~ update in-place

Terraform will perform the following actions:

akamai_dns_record.acc_companydomain_com-txt will be updated in-place

~ resource "akamai_dns_record" "acc_companydomain_com-txt" { active = true id = "acc.companydomain.com-acc.companydomain.com-TXT-c007526e74222c0861d69a9e9fd662ff7048459a" name = "acc.companydomain.com" recordtype = "TXT" ~ target = [ "OneWord",

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


Note: You didn't specify an "-out" parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if "terraform apply" is subsequently run.

3. `terraform apply`

akamai_dns_record.acc_companydomain_com-txt: Refreshing state... [id=acc.companydomain.com-acc.companydomain.com-TXT-c007526e74222c0861d69a9e9fd662ff7048459a] akamai_dns_record.acc_companydomain_com-txt: Modifying... [id=acc.companydomain.com-acc.companydomain.com-TXT-c007526e74222c0861d69a9e9fd662ff7048459a] akamai_dns_record.acc_companydomain_com-txt: Modifications complete after 1s [id=acc.companydomain.com-acc.companydomain.com-TXT-0641b85a3ea35d6cf776c234c0906ae5f0638d79]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.


### DNS dig

dig acc.companydomain.com. TXT @a1-225.akam.net

; <<>> DiG 9.10.6 <<>> acc.companydomain.com. TXT @a1-225.akam.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61846 ;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;acc.companydomain.com. IN TXT

;; ANSWER SECTION: acc.companydomain.com. 3600 IN TXT "OneWord" acc.companydomain.com. 3600 IN TXT "Two" "Words"

;; Query time: 46 msec ;; SERVER: 2600:1401:2::e1#53(2600:1401:2::e1) ;; WHEN: Wed Jul 31 15:54:31 CEST 2019 ;; MSG SIZE rcvd: 93



Note: _actual domain name replaced with "companydomain"_

### Comment
Not sure if this should be flagged as a bug or not, as there is no example available in github for multi-line TXT records and maybe I just need a tad of education on how I should write that target block.
martinstibbe commented 4 years ago

Here is a working example that would yield this

resource "akamai_dns_record" "acc_companydomain_com-txt" { zone = "${local.zone}" name = "akavdev.net" recordtype = "TXT" ttl = 300 active = true target = [ "\"OneWord\"", "\"Two Words\"" ] }

"" = " \ "

akavdev.net. 300 IN TXT "OneWord" akavdev.net. 300 IN TXT "Two Words"