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

provide epoch time (integer) instead timestamp string #25802

Closed
toralf opened this issue Aug 11, 2020 · 5 comments
Closed

provide epoch time (integer) instead timestamp string #25802

toralf opened this issue Aug 11, 2020 · 5 comments

Comments

@toralf
Copy link

toralf commented Aug 11, 2020

Current Terraform Version

$ terraform version
Terraform v0.12.24

Use-cases

Calculate diff eg.:

let "diff = $(date +%s) - $epochtime"

Attempted Solutions

Proposal

References

@toralf toralf added enhancement new new issue not yet triaged labels Aug 11, 2020
@toralf toralf changed the title provide epoch time (integer) isnead timestamp string provide epoch time (integer) instead timestamp string Aug 11, 2020
@smutel
Copy link

smutel commented Aug 18, 2020

Or add sequence in formatdate function to be able to convert it in epoch ?

@toralf
Copy link
Author

toralf commented Aug 18, 2020

Or add sequence in formatdate function to be able to convert it in epoch ?

better: "do not convert it from epoch into a string" :-)

@crw
Copy link
Collaborator

crw commented Mar 7, 2024

Thank you for your continued interest in this issue.

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!

@austinvalle
Copy link
Member

Hey everyone 👋🏻 ,

The hashicorp/time provider has just released a new rfc3339_parse function in v0.11 which should allow you to grab the unix time (along with other data about an RFC3339 timestamp, example below using the built-in plantimestamp() function).

You can test this out now with Terraform v1.8.0-beta1 or wait for the upcoming v1.8.0 release.

# Configuration using provider functions must include required_providers configuration.
terraform {
  required_providers {
    time = {
      source  = "hashicorp/time"
      version = "0.11.1"
    }
  }
  # Provider functions require Terraform 1.8 and later.
  required_version = ">= 1.8.0"
}

locals {
  plan_time = provider::time::rfc3339_parse(plantimestamp())
}

output "unix" {
  value = local.plan_time.unix
}
 $ terraform plan

Changes to Outputs:
  + unix = 1710201187

If you run into any problems with the new function, please create an issue over in the time provider issue tracker, thanks!

@crw crw closed this as completed Mar 12, 2024
Copy link

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.

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

No branches or pull requests

5 participants