time_static (Resource)

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.

Example Usage

Basic Usage

resource "time_static" "example" {}

output "current_time" {
  value = time_static.example.rfc3339
}

Triggers Usage

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) ...
}

Schema

Optional

Read-Only

Import

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.