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

introduces base32 related encoding functions with documentation #29127

Closed
wants to merge 2 commits into from
Closed

Conversation

ufukty
Copy link

@ufukty ufukty commented Jul 9, 2021

Necessity

Base32 is used for OTP secrets, it is nice to be able to produce unique keys for each server via Terraform.

Features

Functions introduces:

  • base32encode
  • base32decode
  • textencodebase32
  • textdecodebase32

and related docs with updated website/layout file.

Misc

I used base64 functions as examples for implementations. Changed 64's with 32's. Updated the examples with valid base32 encodings. 4 documentation page for each function has been added. Links for those pages added to website layout page too.

…ode, textencodebase32, textdecodebase32 and related docs with updated website/layout file
@ufukty
Copy link
Author

ufukty commented Jul 9, 2021

Circle complains about those valid URLs. I don't understand what is wrong.

Checking URLs in the following pages:
- website/docs/language/functions/base32decode.html.md
- website/docs/language/functions/base32encode.html.md
- website/docs/language/functions/textdecodebase32.html.md
- website/docs/language/functions/textencodebase32.html.md


Results:
=== Found broken links! ===
Fix before merging... or if they're not really broken, explain why.

website/docs/language/functions/base32decode.html.md
  - Broken link: https://tools.ietf.org/html/rfc4648#section-6
    [302 Found] https://tools.ietf.org/html/rfc4648#section-6

website/docs/language/functions/base32encode.html.md
  - Broken link: https://tools.ietf.org/html/rfc4648#section-6
    [302 Found] https://tools.ietf.org/html/rfc4648#section-6

website/docs/language/functions/textdecodebase32.html.md
  - Broken link: https://tools.ietf.org/html/rfc4648#section-6
    [302 Found] https://tools.ietf.org/html/rfc4648#section-6

website/docs/language/functions/textencodebase32.html.md
  - Broken link: https://tools.ietf.org/html/rfc4648#section-6
    [302 Found] https://tools.ietf.org/html/rfc4648#section-6


Exited with code exit status 1
CircleCI received exit code 1

@mpalmer
Copy link

mpalmer commented Sep 28, 2021

The URLs are "invalid" because they redirect somewhere else; you should use the redirect destination in the docs.

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

@crw
Copy link
Contributor

crw commented Mar 25, 2022

Hi @ufukty, thanks for the submission! To set expectations, right now we generally are not reviewing submissions for new functions. This may change in the future, however. In the meantime, we would like to hear more about your use case. You say "base32 is used for OTP secrets," can you say more? What provider are you using, how would base32 functions be used with such a provider in your workflow, any info that would help us understand this use case? Thanks so much! We appreciate any input.

@ufukty
Copy link
Author

ufukty commented Apr 2, 2022

Hi @crw,

  • base32 encoding can be used for variety of reasons. Creating OTP secrets is just one use case of it.
  • I always thought using this function with a provisioner, so it is not tightly related with providers.

Example use case

Think about you are configuring a OTP secret for a user of one of your VPN server as part of Multi Factor Authentication.

provisioner "file" {
    content     = "ufukty: ${ substr(base32encode(uuid()), 0, 32) }"
    destination = "/etc/openvpn/otp-secret.yml"
  }

Creating new secret at each deployment instead baking one token into golden image, lets us to use different tokens for each VPN server we have, and keep our tokens fresh. Currently I use a bash script for such problem, but above example looks cleaner and coherent. After, new secrets will be presented to user or saved into state file, so he can register it to the key generator app in his phone.

@mpalmer
Copy link

mpalmer commented Jun 7, 2022

The use-case for base32 encoding is broad and easy to explain -- anywhere you want to encode a sequence of octets as a human-readable string that is resistant to character confusion.

@deepankarsharma
Copy link

I would find base32 encoding useful as well. Google cloud is very restrictive in what it accepts in labels (lower case only) and I want to base32 encode tags, label keys and label values before setting them on google cloud instances.

@ufukty
Copy link
Author

ufukty commented Aug 18, 2022

After I sent this PR, hashicorp announced they won't review PR's due to the lack of enough human resource. I don't know if that's still relevant. I hope this one reviewed and merged soon.

@crw
Copy link
Contributor

crw commented Aug 19, 2022

I can provide an update. At some point in the future, we plan to provide the ability to create "function providers." Function providers would allow our community to create their own functions, or multiple implementations of the same function, and apply them without having to go through our code review process.

This function would be a perfect candidate for a plugin function provider, as opposed to a function built into Terraform. As such it is waiting for the implementation of plugin function providers. For more info and discussion on these topics, please see:

Thanks for this submission! I will keep you posted on future updates.

@ufukty
Copy link
Author

ufukty commented Aug 19, 2022

@crw Thanks for answer. Are you saying that hashicorp makes dozens of PRs like this sit&wait in a queue until you finish a new feature you can not quote ETA. And presumably each PR introduces new features that has potential to make terraform more useful for larger userbase and increase the reach. Seems like a business decision that wastes potential and time. Not my company tho. Kudos for great work so far. 🎉🥳

@crw
Copy link
Contributor

crw commented Aug 20, 2022

Hi @ufukty, thanks for your response. I would frame it as, there are dozens (upon dozens) of often competing ideas for what should be added to Terraform. Meanwhile, users are expecting a level of stability and resiliency that is increasingly difficult to maintain as more features are added to the product. Balancing which features to add, and how to make it possible for users to be more creative and less restrained through providers, is the principle challenge of the core engineering team. It is not easy, but we're doing the best we can! Thanks again for your response and for your continued interest and patience.

@ufukty
Copy link
Author

ufukty commented Aug 20, 2022

@crw Thanks for answer. That makes sense now. Looking forward for release.

@crw
Copy link
Contributor

crw commented Mar 7, 2024

Thank you for your continued interest in this PR.

Terraform version 1.8 launches with support of provider-defined functions. It is now possible to implement your own functions! We would love to see this implemented as a provider-defined function.

Please see the provider-defined functions documentation to learn how to implement functions in your providers. If you are new to provider development, learn how to create a new provider with the Terraform Plugin Framework. If you have any questions, please visit the Terraform Plugin Development category in our official forum.

We hope this feature unblocks future function development and provides more flexibility for the Terraform community. Thank you for your continued support of Terraform!

@crw crw closed this Mar 7, 2024
Copy link
Contributor

github-actions bot commented Apr 7, 2024

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants