Giter Club home page Giter Club logo

Comments (9)

kimdre avatar kimdre commented on June 17, 2024

You should use jsonencode for things like dkim records:

value = jsonencode("v=DKIM1;h=sha256;k=rsa;s=email;p=MIIBIjAN...")

from terraform-provider-hetznerdns.

ThomasLandauer avatar ThomasLandauer commented on June 17, 2024

@kimdre Sorry, I edited the question a lot after your comment. But in any case: I just tried jsconencode, and it doesn't make a difference.

from terraform-provider-hetznerdns.

kimdre avatar kimdre commented on June 17, 2024

The splitting is normal for long records like dkim, as the length of a single string in TXT records is limited to 255 bytes. It's normal though and the only workaround for this is to replace your single string with the splitted one that terraform shows as the current value before performing actions.

from terraform-provider-hetznerdns.

kimdre avatar kimdre commented on June 17, 2024

A nice workaround to split recods automatically is described in a similiar issue related to route53 on aws: hashicorp/terraform-provider-aws#14941 (comment)

from terraform-provider-hetznerdns.

ThomasLandauer avatar ThomasLandauer commented on June 17, 2024

Thanks, here's what I came up with after some trial and error: #56
jsonencode takes care of escaping the quotes, and the last "" is to get the blank character at the end.
Do you see a nicer way?

from terraform-provider-hetznerdns.

kimdre avatar kimdre commented on June 17, 2024

I thought of the other workaround under my linked comment, which splits the string when needed (after every 255th char). However I have not tried it.

from terraform-provider-hetznerdns.

ThomasLandauer avatar ThomasLandauer commented on June 17, 2024

Oh, I've overlooked that. However, it's overescaping (\"\"), so jsonencode would probably be required as well.
Anyway, I've already spent too much time for this - if anybody finds a cleaner solution, feel free to update my example in README! :-)

from terraform-provider-hetznerdns.

kimdre avatar kimdre commented on June 17, 2024

I just tried it out with a combination of your example and the mentioned workaround with small changes:
This not only splits the string every 255th character but also adds \" at the start and the space at the end just like hetzner wants it.

#DKIM record
locals {
  dkim = "v=DKIM1;k=rsa;t=s;s=email;p=abc"
}

resource "hetznerdns_record" "example_com_dkim" {
  zone_id = hetznerdns_zone.example_com.id
  name    = "dkim._domainkey"
  type    = "TXT"
  value   = join("\"", [
    "",
    replace(local.dkim, "/(.{255})/", "$1\" \""),
    " "
  ])

}

from terraform-provider-hetznerdns.

ThomasLandauer avatar ThomasLandauer commented on June 17, 2024

Indeed, this works for me too. I added it as alternative way - since it isn't really simpler than the other way ;-)

from terraform-provider-hetznerdns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.