-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Add timediff datetime function #23429
Comments
Hi @adongy! Sorry for the long silence here. I ended up implementing something related to this for a different reason, and only afterwards found this older issue covering the use-case. The forthcoming Terraform v1.3.0 will have a That doesn't directly address your use-case here, but it can then be combined with As you noted, Terraform doesn't have much existing functionality for computing with durations in particular, and so the design of I'm going to close this issue not because I believe In the meantime, the Thanks! |
Hello, I left the company that wanted to leverage that usecase, but good to hear an API for providing custom functions is getting some traction 👍 |
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. |
Current Terraform Version
Use-cases
In Vault, many resources accept a
ttl
kind of argument which is usually a number of seconds a token can be valid for. I'd like to create a policy to allow users to be able to generate tokens up until a certain point in time.Example: a contractor joins my company for a contract ending on Dec 31th, I'll set max_ttl to
Dec 31th - Current date
for tokens issued to the contractor.Terraform currently provides a few datetime related functions, including
timeadd
, but it only supports a datetime and a duration as arguments.Attempted Solutions
Did not find any solution to this, except computing the ttl myself.
Proposal
Add a
timediff(timestamp, timestamp)
function which would return a number (the number of seconds between the two timestamps). Returning a duration would be preferable to avoid huge durations converting into a big number, but there are no duration utils in Terraform which would make further usage complex.https://github.com/hashicorp/terraform/blob/master/lang/funcs/datetime.go
References
The text was updated successfully, but these errors were encountered: