Skip to content

New Action: time_sleep#467

Open
benkelly123 wants to merge 1 commit intohashicorp:mainfrom
benkelly123:feat/time-sleep-action
Open

New Action: time_sleep#467
benkelly123 wants to merge 1 commit intohashicorp:mainfrom
benkelly123:feat/time-sleep-action

Conversation

@benkelly123
Copy link
Copy Markdown

@benkelly123 benkelly123 commented Feb 13, 2026

Summary

Implements time_sleep as a Terraform action, enabling event-driven sleep functionality. Unlike the existing resource which manages sleep as state, this action executes sleep on-demand in response to action_trigger events.

Changes

  • New time_sleep action implementation
  • Simplified logic compared to resource version:
    • Only a single duration parameter rather than one for both create/destroy
    • No trigger logic (this is handled by Terraform itself)
  • Reuses duration parsing and validation from existing resource

Limitations

Due to the nature of Terraform Actions, there is only functionality to trigger this after an apply or update, not a destroy. For use-cases where a sleep is needed after a destroy the resource block will still be required.

Fixes

#455

Example Usage

resource "terraform_data" "trigger" {
  lifecycle {
    action_trigger {
      events  = [after_create]
      actions = [action.time_sleep.sleep]
    }
  }
}

action "time_sleep" "sleep" {
  config {
    duration = "10s"
  }
}

Tests

$ TF_ACC=1 go test -v ./internal/provider
=== RUN   TestActionTimeSleepInvoke
--- PASS: TestActionTimeSleepInvoke (1.00s)
=== RUN   TestAccTimeSleepAction_Basic
--- PASS: TestAccTimeSleepAction_Basic (0.49s)
=== RUN   TestAccTimeSleepAction_Validators
--- PASS: TestAccTimeSleepAction_Validators (0.13s)
=== RUN   TestAccTimeSleepAction_ValidDurations
--- PASS: TestAccTimeSleepAction_ValidDurations (0.66s)
=== RUN   TestDurationParse_valid
--- PASS: TestDurationParse_valid (0.91s)
=== RUN   TestDurationParse_invalid
--- PASS: TestDurationParse_invalid (0.08s)
=== RUN   TestRFC3339Parse_UTC
--- PASS: TestRFC3339Parse_UTC (0.48s)
=== RUN   TestRFC3339Parse_offset
--- PASS: TestRFC3339Parse_offset (0.22s)
=== RUN   TestRFC3339Parse_invalid
--- PASS: TestRFC3339Parse_invalid (0.08s)
=== RUN   TestUnixTimestampParseFunction_Valid
=== PAUSE TestUnixTimestampParseFunction_Valid
=== RUN   TestUnixTimestampParseFunction_Null
=== PAUSE TestUnixTimestampParseFunction_Null
=== RUN   TestAccTimeOffset_Triggers
--- PASS: TestAccTimeOffset_Triggers (1.60s)
=== RUN   TestAccTimeOffset_OffsetDays
--- PASS: TestAccTimeOffset_OffsetDays (0.56s)
=== RUN   TestAccTimeOffset_OffsetHours
--- PASS: TestAccTimeOffset_OffsetHours (0.57s)
=== RUN   TestAccTimeOffset_OffsetMinutes
--- PASS: TestAccTimeOffset_OffsetMinutes (0.52s)
=== RUN   TestAccTimeOffset_OffsetMonths
--- PASS: TestAccTimeOffset_OffsetMonths (0.53s)
=== RUN   TestAccTimeOffset_OffsetSeconds
--- PASS: TestAccTimeOffset_OffsetSeconds (0.52s)
=== RUN   TestAccTimeOffset_OffsetYears
--- PASS: TestAccTimeOffset_OffsetYears (0.52s)
=== RUN   TestAccTimeOffset_OffsetYearsAndMonths
--- PASS: TestAccTimeOffset_OffsetYearsAndMonths (0.53s)
=== RUN   TestAccTimeOffset_Upgrade
--- PASS: TestAccTimeOffset_Upgrade (1.47s)
=== RUN   TestAccTimeOffset_Validators
--- PASS: TestAccTimeOffset_Validators (0.08s)
=== RUN   TestAccTimeRotating_Triggers
=== PAUSE TestAccTimeRotating_Triggers
=== RUN   TestAccTimeRotating_ComputedRFC3339RotationDays_basic
=== PAUSE TestAccTimeRotating_ComputedRFC3339RotationDays_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationDays_basic
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationDays_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationDays_expired
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationDays_expired
=== RUN   TestAccTimeRotating_ComputedRFC3339RotationHours_basic
=== PAUSE TestAccTimeRotating_ComputedRFC3339RotationHours_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationHours_basic
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationHours_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationHours_expired
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationHours_expired
=== RUN   TestAccTimeRotating_ComputedRFC3339RotationMinutes_basic
=== PAUSE TestAccTimeRotating_ComputedRFC3339RotationMinutes_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_basic
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_expired
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_expired
=== RUN   TestAccTimeRotating_ComputedRFC3339RotationMonths_basic
=== PAUSE TestAccTimeRotating_ComputedRFC3339RotationMonths_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationMonths_basic
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationMonths_basic
=== RUN   TestAccTimeRotating_RotationMonths_expired
=== PAUSE TestAccTimeRotating_RotationMonths_expired
=== RUN   TestAccTimeRotating_ComputedRFC3339RotationRfc3339_basic
=== PAUSE TestAccTimeRotating_ComputedRFC3339RotationRfc3339_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationRfc3339_basic
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationRfc3339_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC339RotationRfc3339_expired
=== PAUSE TestAccTimeRotating_ConfiguredRFC339RotationRfc3339_expired
=== RUN   TestAccTimeRotating_ComputedRFC3339RotationYears_basic
=== PAUSE TestAccTimeRotating_ComputedRFC3339RotationYears_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationYears_basic
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationYears_basic
=== RUN   TestAccTimeRotating_ConfiguredRFC3339RotationYears_expired
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339RotationYears_expired
=== RUN   TestAccTimeRotating_ComputedRFC3339_RotationDays_ToRotationMonths
=== PAUSE TestAccTimeRotating_ComputedRFC3339_RotationDays_ToRotationMonths
=== RUN   TestAccTimeRotating_ConfiguredRFC3339_RotationDays_ToRotationMonths
=== PAUSE TestAccTimeRotating_ConfiguredRFC3339_RotationDays_ToRotationMonths
=== RUN   TestAccTimeRotating_UpdateUnknownValue
=== PAUSE TestAccTimeRotating_UpdateUnknownValue
=== RUN   TestAccTimeRotating_LifecycleReplaceTriggeredBy
=== PAUSE TestAccTimeRotating_LifecycleReplaceTriggeredBy
=== RUN   TestAccTimeRotation_Upgrade
--- PASS: TestAccTimeRotation_Upgrade (1.49s)
=== RUN   TestAccTimeRotating_Validators
=== PAUSE TestAccTimeRotating_Validators
=== RUN   TestResourceTimeSleepCreate
--- PASS: TestResourceTimeSleepCreate (1.00s)
=== RUN   TestResourceTimeSleepDelete
--- PASS: TestResourceTimeSleepDelete (1.00s)
=== RUN   TestAccTimeSleep_CreateDuration
--- PASS: TestAccTimeSleep_CreateDuration (0.47s)
=== RUN   TestAccTimeSleep_DestroyDuration
--- PASS: TestAccTimeSleep_DestroyDuration (0.40s)
=== RUN   TestAccTimeSleep_Triggers
--- PASS: TestAccTimeSleep_Triggers (2.50s)
=== RUN   TestAccTimeSleep_Upgrade
--- PASS: TestAccTimeSleep_Upgrade (1.32s)
=== RUN   TestAccTimeSleep_Validators
--- PASS: TestAccTimeSleep_Validators (0.10s)
=== RUN   TestAccTimeStatic_basic
--- PASS: TestAccTimeStatic_basic (0.34s)
=== RUN   TestAccTimeStatic_Triggers
--- PASS: TestAccTimeStatic_Triggers (1.53s)
=== RUN   TestAccTimeStatic_Rfc3339
--- PASS: TestAccTimeStatic_Rfc3339 (0.36s)
=== RUN   TestAccTimeStatic_Upgrade
--- PASS: TestAccTimeStatic_Upgrade (1.59s)
=== RUN   TestAccTimeStatic_Validators
--- PASS: TestAccTimeStatic_Validators (0.08s)
=== CONT  TestUnixTimestampParseFunction_Valid
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationMonths_basic
--- PASS: TestUnixTimestampParseFunction_Valid (0.30s)
=== CONT  TestAccTimeRotating_Validators
--- PASS: TestAccTimeRotating_Validators (0.15s)
=== CONT  TestAccTimeRotating_LifecycleReplaceTriggeredBy
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationMonths_basic (0.82s)
=== CONT  TestAccTimeRotating_UpdateUnknownValue
--- PASS: TestAccTimeRotating_UpdateUnknownValue (0.45s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339_RotationDays_ToRotationMonths
--- PASS: TestAccTimeRotating_ConfiguredRFC3339_RotationDays_ToRotationMonths (0.47s)
=== CONT  TestAccTimeRotating_ComputedRFC3339_RotationDays_ToRotationMonths
--- PASS: TestAccTimeRotating_ComputedRFC3339_RotationDays_ToRotationMonths (0.47s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationYears_expired
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationYears_expired (0.50s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationYears_basic
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationYears_basic (0.65s)
=== CONT  TestAccTimeRotating_ComputedRFC3339RotationYears_basic
--- PASS: TestAccTimeRotating_ComputedRFC3339RotationYears_basic (0.62s)
=== CONT  TestAccTimeRotating_ConfiguredRFC339RotationRfc3339_expired
--- PASS: TestAccTimeRotating_ConfiguredRFC339RotationRfc3339_expired (0.30s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationRfc3339_basic
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationRfc3339_basic (0.59s)
=== CONT  TestAccTimeRotating_ComputedRFC3339RotationRfc3339_basic
--- PASS: TestAccTimeRotating_ComputedRFC3339RotationRfc3339_basic (0.59s)
=== CONT  TestAccTimeRotating_RotationMonths_expired
--- PASS: TestAccTimeRotating_RotationMonths_expired (0.30s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationHours_basic
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationHours_basic (0.59s)
=== CONT  TestAccTimeRotating_ComputedRFC3339RotationMonths_basic
--- PASS: TestAccTimeRotating_ComputedRFC3339RotationMonths_basic (0.58s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_expired
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_expired (0.30s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_basic
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationMinutes_basic (0.59s)
=== CONT  TestAccTimeRotating_ComputedRFC3339RotationMinutes_basic
--- PASS: TestAccTimeRotating_ComputedRFC3339RotationMinutes_basic (0.57s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationHours_expired
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationHours_expired (0.29s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationDays_basic
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationDays_basic (0.61s)
=== CONT  TestAccTimeRotating_ComputedRFC3339RotationHours_basic
--- PASS: TestAccTimeRotating_ComputedRFC3339RotationHours_basic (0.58s)
=== CONT  TestAccTimeRotating_ConfiguredRFC3339RotationDays_expired
--- PASS: TestAccTimeRotating_ConfiguredRFC3339RotationDays_expired (0.29s)
=== CONT  TestAccTimeRotating_Triggers
--- PASS: TestAccTimeRotating_Triggers (1.57s)
=== CONT  TestAccTimeRotating_ComputedRFC3339RotationDays_basic
--- PASS: TestAccTimeRotating_ComputedRFC3339RotationDays_basic (0.60s)
=== CONT  TestUnixTimestampParseFunction_Null
--- PASS: TestUnixTimestampParseFunction_Null (0.08s)
--- PASS: TestAccTimeRotating_LifecycleReplaceTriggeredBy (61.01s)
PASS
ok      github.com/hashicorp/terraform-provider-time/internal/provider  84.629s

@benkelly123 benkelly123 requested a review from a team as a code owner February 13, 2026 09:51
@hashicorp-cla-app
Copy link
Copy Markdown

hashicorp-cla-app bot commented Feb 13, 2026

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant