hashicorp / terraform-provider-time

Utility provider that provides Time-Based Resources
https://registry.terraform.io/providers/hashicorp/time/latest
Mozilla Public License 2.0
103 stars 30 forks source link

resource/time_static: Enhance plan output for config-defined `rfc3339` values #295

Closed austinvalle closed 2 weeks ago

austinvalle commented 5 months ago

Closes #255

This PR introduces new plan enhancements to the time_static resource to ensure config-provided values for rfc3339 result in known values in the plan.

resource "time_static" "example" {
  rfc3339 = "2024-02-23T21:08:42Z"
}

Before

 $ terraform apply -auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # time_static.example will be created
  + resource "time_static" "example" {
      + day     = (known after apply)
      + hour    = (known after apply)
      + id      = (known after apply)
      + minute  = (known after apply)
      + month   = (known after apply)
      + rfc3339 = "2024-02-23T21:08:42Z"
      + second  = (known after apply)
      + unix    = (known after apply)
      + year    = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
time_static.example: Creating...
time_static.example: Creation complete after 0s [id=2024-02-23T21:08:42Z]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

After

 $ terraform apply -auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # time_static.example will be created
  + resource "time_static" "example" {
      + day     = 23
      + hour    = 21
      + id      = "2024-02-23T21:08:42Z"
      + minute  = 8
      + month   = 2
      + rfc3339 = "2024-02-23T21:08:42Z"
      + second  = 42
      + unix    = 1708722522
      + year    = 2024
    }

Plan: 1 to add, 0 to change, 0 to destroy.
time_static.example: Creating...
time_static.example: Creation complete after 0s [id=2024-02-23T21:08:42Z]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
austinvalle commented 5 months ago

I replaced the awkward NumberRegularExpression with an Int64Between check in d73f9a9168e7dd1554fe1fbe2cb8f4f676405852