Skip to content

Commit 094ec9f

Browse files
committed
feat: add temporal sechdule resource
Signed-off-by: Shamil Ganiev <[email protected]>
1 parent 0959566 commit 094ec9f

File tree

19 files changed

+1725
-24
lines changed

19 files changed

+1725
-24
lines changed

docker-compose/docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ services:
4444
- ENABLE_ES=true
4545
- ES_SEEDS=elasticsearch
4646
- ES_VERSION=v7
47+
- LOG_LEVEL=debug
4748
image: temporalio/auto-setup:${TEMPORAL_VERSION}
4849
networks:
4950
- temporal-network

docs/data-sources/search_attribute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Temporal Search Attribute data source
1515
```terraform
1616
# Get data of the example search attribute, with or without explicitly providing a namespace
1717
data "temporal_search_attribute" "example_search_attribute" {
18-
name = "example"
18+
name = "example"
1919
namespace = "default"
2020
}
2121

docs/index.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@ description: |-
1313
## Example Usage
1414

1515
```terraform
16+
terraform {
17+
required_providers {
18+
temporal = {
19+
source = "platacard/temporal"
20+
}
21+
}
22+
}
23+
1624
provider "temporal" {
17-
host = "127.0.0.1"
18-
port = "7233"
25+
host = "127.0.0.1"
26+
port = "7233"
27+
insecure = true
28+
}
29+
30+
# Manage an example namespace.
31+
resource "temporal_namespace" "example" {
32+
name = "example"
33+
description = "This is example namespace"
34+
owner_email = "[email protected]"
1935
}
2036
```
2137

docs/resources/schedule.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "temporal_schedule Resource - terraform-provider-temporal"
4+
subcategory: ""
5+
description: |-
6+
Temporal Schedule resource for managing workflow schedules
7+
---
8+
9+
# temporal_schedule (Resource)
10+
11+
Temporal Schedule resource for managing workflow schedules
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Manage an example schedule.
17+
resource "temporal_schedule" "daily_cleanup" {
18+
namespace = default
19+
schedule_id = "daily-cleanup-task"
20+
21+
spec = {
22+
intervals = [{
23+
every = "24h"
24+
offset = "3h"
25+
}]
26+
27+
calendar_items = [{
28+
year = "2025"
29+
month = "1,3,7,11"
30+
day_of_month = "1,11"
31+
hour = "11-14"
32+
}]
33+
34+
time_zone = "UTC"
35+
}
36+
37+
state = {}
38+
39+
policy_config = {
40+
catchup_window = "1m"
41+
}
42+
43+
action = {
44+
workflow = {
45+
workflow_type = "CleanupWorkflow"
46+
task_queue = "cleanup-queue-1"
47+
workflow_id = "cleanup-wf-test"
48+
49+
input = jsonencode({
50+
retention_days = 30
51+
dry_run = false
52+
})
53+
54+
execution_timeout = "1h"
55+
run_timeout = "30m"
56+
task_timeout = "10s"
57+
58+
retry_policy = {
59+
initial_interval = "1s"
60+
backoff_coefficient = 2.0
61+
maximum_interval = "100s"
62+
maximum_attempts = 5
63+
}
64+
}
65+
}
66+
}
67+
```
68+
69+
<!-- schema generated by tfplugindocs -->
70+
## Schema
71+
72+
### Required
73+
74+
- `action` (Attributes) Action to execute on schedule (see [below for nested schema](#nestedatt--action))
75+
- `namespace` (String) Namespace where the schedule resides
76+
- `policy_config` (Attributes) Schedule policy configuration (see [below for nested schema](#nestedatt--policy_config))
77+
- `schedule_id` (String) Unique identifier for the schedule
78+
- `spec` (Attributes) Schedule specification (see [below for nested schema](#nestedatt--spec))
79+
- `state` (Attributes) Schedule state (see [below for nested schema](#nestedatt--state))
80+
81+
### Optional
82+
83+
- `memo` (Map of String) Non-indexed key-value pairs for metadata
84+
85+
<a id="nestedatt--action"></a>
86+
### Nested Schema for `action`
87+
88+
Required:
89+
90+
- `workflow` (Attributes) Workflow action (see [below for nested schema](#nestedatt--action--workflow))
91+
92+
<a id="nestedatt--action--workflow"></a>
93+
### Nested Schema for `action.workflow`
94+
95+
Required:
96+
97+
- `task_queue` (String) Task Queue
98+
- `workflow_id` (String) Workflow ID
99+
- `workflow_type` (String) Workflow Type
100+
101+
Optional:
102+
103+
- `execution_timeout` (String) Execution timeout
104+
- `input` (String) Workflow input (JSON)
105+
- `run_timeout` (String) Run timeout
106+
- `task_timeout` (String) Task timeout
107+
108+
109+
110+
<a id="nestedatt--policy_config"></a>
111+
### Nested Schema for `policy_config`
112+
113+
Optional:
114+
115+
- `catchup_window` (String) Maximum catch-up time for when the Service is unavailable
116+
- `overlap_policy` (String) Policy for handling overlapping Workflow Executions. Accepted values: Skip, BufferOne, BufferAll, CancelOther, TerminateOther, AllowAll
117+
- `pause_on_failure` (Boolean) Pause the schedule on action failure
118+
119+
120+
<a id="nestedatt--spec"></a>
121+
### Nested Schema for `spec`
122+
123+
Optional:
124+
125+
- `calendar_items` (Attributes List) Calendar expressions for schedule (see [below for nested schema](#nestedatt--spec--calendar_items))
126+
- `cron_items` (List of String) Traditional cron expressions (e.g. '15 8 * * *')
127+
- `end_time` (String) End time of the schedule (RFC3339)
128+
- `intervals` (Attributes List) Time intervals for schedule (see [below for nested schema](#nestedatt--spec--intervals))
129+
- `jitter` (String) Jitter duration to add randomness to scheduled times
130+
- `start_time` (String) Start time of the schedule (RFC3339)
131+
- `time_zone` (String) Time zone for the schedule
132+
133+
<a id="nestedatt--spec--calendar_items"></a>
134+
### Nested Schema for `spec.calendar_items`
135+
136+
Optional:
137+
138+
- `comment` (String) Optional comment describing this calendar entry
139+
- `day_of_month` (String) Day of month specification (e.g., '1', '1,15', '1-31')
140+
- `day_of_week` (String) Day of week specification in numeric format (e.g., '1', '1-6', '1,3,5')
141+
- `hour` (String) Hour specification (e.g., '9', '9-17', '11-14')
142+
- `minute` (String) Minute specification (e.g., '0', '0,30', '*/15', '*')
143+
- `month` (String) Month specification in numeric format (e.g., '1', '1,2,9', '1-12')
144+
- `second` (String) Second specification (e.g., '0', '0,30', '*')
145+
- `year` (String) Year specification (e.g., '2022', '2022-2025')
146+
147+
148+
<a id="nestedatt--spec--intervals"></a>
149+
### Nested Schema for `spec.intervals`
150+
151+
Required:
152+
153+
- `every` (String) Duration of the interval (e.g., '24h', '7d')
154+
155+
Optional:
156+
157+
- `offset` (String) Offset from the interval (e.g., '1h')
158+
159+
160+
161+
<a id="nestedatt--state"></a>
162+
### Nested Schema for `state`
163+
164+
Optional:
165+
166+
- `limited_actions` (Boolean) Whether the schedule is limited to a specific number of actions
167+
- `notes` (String) Initial notes
168+
- `paused` (Boolean) Pause the Schedule immediately on creation
169+
- `remaining_actions` (Number) Total allowed actions
170+
171+
## Import
172+
173+
Import is supported using the following syntax:
174+
175+
```shell
176+
# A schedule can be imported by specifying 'namespace:schedule_id'
177+
terraform import temporal_schedule.example_schedule default:example
178+
179+
180+
# A schedule can also be imported by specifying just 'schedule_id' ('default' namespace will be used)
181+
terraform import temporal_schedule.example_schedule example
182+
```

docs/resources/search_attribute.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Temporal Search Attribute resource
1515
```terraform
1616
# Manage an example search attribute, with or without explicitly providing a namespace
1717
resource "temporal_search_attribute" "example_search_attribute" {
18-
name = "example"
19-
type = "Bool"
18+
name = "example"
19+
type = "Bool"
2020
namespace = "default"
2121
}
2222

examples/data-sources/temporal_search_attribute/data-source.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Get data of the example search attribute, with or without explicitly providing a namespace
22
data "temporal_search_attribute" "example_search_attribute" {
3-
name = "example"
3+
name = "example"
44
namespace = "default"
55
}
66

examples/provider/provider.tf

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1+
terraform {
2+
required_providers {
3+
temporal = {
4+
source = "platacard/temporal"
5+
}
6+
}
7+
}
8+
19
provider "temporal" {
2-
host = "127.0.0.1"
3-
port = "7233"
10+
host = "127.0.0.1"
11+
port = "7233"
12+
insecure = true
13+
}
14+
15+
# Manage an example namespace.
16+
resource "temporal_namespace" "example" {
17+
name = "example"
18+
description = "This is example namespace"
19+
owner_email = "[email protected]"
420
}

examples/provider/tls/tls.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ terraform {
99
provider "temporal" {
1010
host = "127.0.0.1"
1111
port = "7233"
12-
12+
1313
# Add certs for mTLS auth.
1414
tls {
15-
cert = sensitive(file("path/to/cert.pem"))
16-
key = sensitive(file("path/to/key.pem"))
17-
ca = sensitive(file("path/to/cacerts.pem"))
15+
cert = sensitive(file("path/to/cert.pem"))
16+
key = sensitive(file("path/to/key.pem"))
17+
ca = sensitive(file("path/to/cacerts.pem"))
1818
server_name = "server-name"
1919
}
2020
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# A schedule can be imported by specifying 'namespace:schedule_id'
2+
terraform import temporal_schedule.example_schedule default:example
3+
4+
5+
# A schedule can also be imported by specifying just 'schedule_id' ('default' namespace will be used)
6+
terraform import temporal_schedule.example_schedule example
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Manage an example schedule.
2+
resource "temporal_schedule" "daily_cleanup" {
3+
namespace = default
4+
schedule_id = "daily-cleanup-task"
5+
6+
spec = {
7+
intervals = [{
8+
every = "24h"
9+
offset = "3h"
10+
}]
11+
12+
calendar_items = [{
13+
year = "2025"
14+
month = "1,3,7,11"
15+
day_of_month = "1,11"
16+
hour = "11-14"
17+
}]
18+
19+
time_zone = "UTC"
20+
}
21+
22+
state = {}
23+
24+
policy_config = {
25+
catchup_window = "1m"
26+
}
27+
28+
action = {
29+
workflow = {
30+
workflow_type = "CleanupWorkflow"
31+
task_queue = "cleanup-queue-1"
32+
workflow_id = "cleanup-wf-test"
33+
34+
input = jsonencode({
35+
retention_days = 30
36+
dry_run = false
37+
})
38+
39+
execution_timeout = "1h"
40+
run_timeout = "30m"
41+
task_timeout = "10s"
42+
43+
retry_policy = {
44+
initial_interval = "1s"
45+
backoff_coefficient = 2.0
46+
maximum_interval = "100s"
47+
maximum_attempts = 5
48+
}
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)