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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new interpolation function uuidv5 #21197

Closed
wants to merge 2 commits into from

Conversation

lscheidler
Copy link
Contributor

it would be nice, if this interpolation function could be added, so it can be used in different use cases.

My use-case for this function is, that it will be used in aws_route53_record resources, so that the sub-domain isn't easily guessed, but anyone knowing the dns name can convert it back to plain text.

resource "aws_route53_record" "client-name-or-domain" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name    = "${uuidv5("dns", "client-name-or-domain")}.example.com"
  type    = "A"
  ttl     = "300"
  records = ["${aws_eip.lb.public_ip}"]
}

@hashicorp-cla
Copy link

hashicorp-cla commented May 3, 2019

CLA assistant check
All committers have signed the CLA.

@apparentlymart
Copy link
Contributor

apparentlymart commented May 3, 2019

Hi @lscheidler! Thanks for working on this.

This seems like a reasonable idea to me, and I'd like to include it. There are unfortuantely a few details we'll need to deal with first though...

Firstly, the v0.11 branch is closed to outside contributions and used for maintenance patch releases only -- primarily backports. Please instead target your change at the master branch for inclusion in a future release. (v0.11 is in maintenance mode now, so no new features will be added to it.)

Secondly, the config/interpolation_funcs.go file is now dead code and will be removed in the near future. Functions are developed instead in the lang/funcs package, where you can find the new implementation of uuid as an example. The new functions mechanism is a little different than the old but for this function in particular (where the inputs and outputs are all just strings) it shouldn't look too different than your implementation in the old way.

Finally, functions now have their own documentation pages, allowing us to give more details on their functionality and show examples of usage. They must also be listed in the nativation so that they can be found. Again, the uuid function is a reasonable template to follow for these.

The uuid function in the master branch (for v0.12 and later) is marked as "impure" because its result will vary across multiple calls for the same input. However, v5 UUIDs depend only on the given namespace and name, so that constraint doesn't apply there: we can leave uuidv5 as a pure function (the default) and thus allow it to be evaluated immediately during plan time, rather than deferred to apply time.

Thanks again for working on this! If you need any help with the above, please do let me know. The master branch is currently feature-frozen until we complete the v0.12.0 release, but we'll look at getting this merged in once the initial v0.12 release is closed.

@lscheidler
Copy link
Contributor Author

Hi @apparentlymart . Thanks for Your input. I am going to create a new pull request on master branch and try to implement it in the lang/funcs package.

@ghost
Copy link

ghost commented Jul 26, 2019

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.

@ghost ghost locked and limited conversation to collaborators Jul 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants