Manages a static time resource, which keeps a locally sourced UTC timestamp stored in the Terraform state. This prevents perpetual differences caused by using the timestamp()
function.
resource "time_static" "example" {}
output "current_time" {
value = time_static.example.rfc3339
}
resource "time_static" "ami_update" {
triggers = {
# Save the time each switch of an AMI id
ami_id = data.aws_ami.example.id
}
}
resource "aws_instance" "server" {
# Read the AMI id "through" the time_static resource to ensure that
# both will change together.
ami = time_static.ami_update.triggers.ami_id
tags = {
AmiUpdateTime = time_static.ami_update.rfc3339
}
# ... (other aws_instance arguments) ...
}
rfc3339
(String) Base timestamp in RFC3339 format (see RFC3339 time string e.g., YYYY-MM-DDTHH:MM:SSZ
). Defaults to the current time.triggers
(Map of String) Arbitrary map of values that, when changed, will trigger a new base timestamp value to be saved. See the main provider documentation for more information.day
(Number) Number day of timestamp.hour
(Number) Number hour of timestamp.id
(String) RFC3339 format of the offset timestamp, e.g. 2020-02-12T06:36:13Z
.minute
(Number) Number minute of timestamp.month
(Number) Number month of timestamp.second
(Number) Number second of timestamp.unix
(Number) Number of seconds since epoch time, e.g. 1581489373
.year
(Number) Number year of timestamp.This resource can be imported using the UTC RFC3339 value, e.g.
terraform import time_static.example 2020-02-12T06:36:13Z
The triggers
argument cannot be imported.