time_offset (Resource)

Manages an offset time resource, which keeps an UTC timestamp stored in the Terraform state that is offset from a locally sourced base timestamp. This prevents perpetual differences caused by using the timestamp() function.

Example Usage

Basic Usage

resource "time_offset" "example" {
  offset_days = 7
}

output "one_week_from_now" {
  value = time_offset.example.rfc3339
}

Multiple Offsets Usage

resource "time_offset" "example" {
  offset_years  = 1
  offset_months = 1
}

output "one_year_and_month_from_now" {
  value = time_offset.example.rfc3339
}

Triggers Usage

resource "time_offset" "ami_update" {
  triggers = {
    # Save the time each switch of an AMI id
    ami_id = data.aws_ami.example.id
  }

  offset_days = 7
}

resource "aws_instance" "server" {
  # Read the AMI id "through" the time_offset resource to ensure that
  # both will change together.
  ami = time_offset.ami_update.triggers.ami_id

  tags = {
    ExpirationTime = time_offset.ami_update.rfc3339
  }

  # ... (other aws_instance arguments) ...
}

Schema

Optional

Read-Only

Import

This resource can be imported using the base UTC RFC3339 timestamp and offset years, months, days, hours, minutes, and seconds, separated by commas (,), e.g.

terraform import time_offset.example 2020-02-12T06:36:13Z,0,0,7,0,0,0

The triggers argument cannot be imported.