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

Add Timestamp Variable #3326

Closed

Conversation

grubernaut
Copy link
Contributor

Adds a timestamp variable, as "${timestamp}", similar to Packer.

Can be useful for naming and other things

Adds a timestamp variable, as "${timestamp}", similar to Packer.

Can be useful for naming and other things
@grubernaut
Copy link
Contributor Author

This fixes #494, but as stated in that issue, should probably wait until #2018 is implemented.

Needs tests and documentation as well

@phinze
Copy link
Contributor

phinze commented Oct 29, 2015

This is a great start, @grubernaut!

However, I think this should be implemented as an interpolation function instead of a variable. The variable route made sense in Packer, since Packer does not have functions like we do.

This also gives us the opportunity to add an optional strftime-style format argument if we'd like.

@grubernaut
Copy link
Contributor Author

Yeah an interpolation function would be a lot cleaner and smoother than this one :)
There is this commit, which I don't believe was ever submitted as a PR that should probably be used instead of this commit: rcostanzo@e6e6e46

@grubernaut grubernaut closed this Oct 29, 2015
@dattatrayakumbhar
Copy link

dattatrayakumbhar commented Dec 1, 2016

Is this available in 0.7.4.
I used below resource with timestamp as name
1.
resource "openstack_compute_instance_v2" "bastion" {
name = "${timestamp()}"

however I got error
Errors:

  • 1:3: unknown function called: timestamp in:

${timestamp()}

  1. Also tried
    resource "openstack_compute_instance_v2" "bastion" {
    name = "${ timestamp }"

however name is set as "${ timestamp }"

Can someone please help ? Am I missing something ?

@phinze
Copy link
Contributor

phinze commented Dec 1, 2016

Hi @dattatrayakumbhar04! There's no Timestamp functionality currently in Terraform. Nowadays it would probably be implemented as a Data Source.

We do have a good story for unique identifiers using the random_id data source, though.

That would look something like this:

data "random_id" "bastion" {
  byte_length = 8
}
resource "openstack_compute_instance_v2" "bastion" {
  name = "bastion-${data.random_id.bastion.hex}"
}

@grubernaut grubernaut deleted the add_timestamp_variable branch December 1, 2016 16:48
@ghost
Copy link

ghost commented Apr 19, 2020

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 Apr 19, 2020
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.

4 participants