Skip to content

Commit b403a08

Browse files
Merge pull request #39 from ctrlplanedev/workflow-resource-provider
feat: workflow resource provider
2 parents fbb90b9 + c767505 commit b403a08

8 files changed

Lines changed: 988 additions & 106 deletions

File tree

docs/resources/workflow.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "ctrlplane_workflow Resource - ctrlplane"
4+
subcategory: ""
5+
description: |-
6+
Manages a workflow in Ctrlplane.
7+
---
8+
9+
# ctrlplane_workflow (Resource)
10+
11+
Manages a workflow in Ctrlplane.
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `name` (String) The name of the workflow.
21+
22+
### Optional
23+
24+
- `inputs` (String) JSON-encoded array of workflow input definitions.
25+
- `job_agent` (Block List) Job agents to dispatch when the workflow runs. (see [below for nested schema](#nestedblock--job_agent))
26+
27+
### Read-Only
28+
29+
- `id` (String) The ID of the workflow.
30+
31+
<a id="nestedblock--job_agent"></a>
32+
### Nested Schema for `job_agent`
33+
34+
Required:
35+
36+
- `config` (Map of String) Configuration for the job agent.
37+
- `name` (String) Name of the job agent entry.
38+
- `ref` (String) ID of the job agent to reference.
39+
- `selector` (String) CEL expression to determine if the job agent should dispatch. Use "true" to always dispatch.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_providers {
3+
ctrlplane = {
4+
source = "ctrlplanedev/ctrlplane"
5+
version = "~> 1"
6+
}
7+
}
8+
}
9+
10+
provider "ctrlplane" {
11+
workspace = var.workspace
12+
url = var.url
13+
api_key = var.api_key
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
variable "workspace" {
2+
type = string
3+
description = "The workspace to use"
4+
}
5+
6+
variable "url" {
7+
type = string
8+
description = "The URL of the Ctrlplane API"
9+
}
10+
11+
variable "api_key" {
12+
type = string
13+
description = "The API key for the Ctrlplane API"
14+
sensitive = true
15+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
resource "ctrlplane_job_agent" "runner_1" {
2+
name = "workflow-runner-1"
3+
4+
test_runner {
5+
delay_seconds = 10
6+
status = "successful"
7+
message = "Test runner job agent"
8+
}
9+
}
10+
11+
resource "ctrlplane_job_agent" "runner_2" {
12+
name = "workflow-runner-2"
13+
14+
test_runner {
15+
delay_seconds = 10
16+
status = "successful"
17+
message = "Test runner job agent"
18+
}
19+
}
20+
21+
resource "ctrlplane_workflow" "example" {
22+
name = "example-workflow"
23+
24+
inputs = jsonencode([
25+
{ key = "environment", type = "string", default = "staging" },
26+
{ key = "retries", type = "number", default = 3 },
27+
{ key = "dryRun", type = "boolean", default = true },
28+
])
29+
30+
job_agent {
31+
name = "workflow-runner-1"
32+
ref = ctrlplane_job_agent.runner_1.id
33+
config = { delaySeconds = "10", message = "Test runner job agent", status = "successful" }
34+
selector = "true"
35+
}
36+
37+
job_agent {
38+
name = "workflow-runner-2"
39+
ref = ctrlplane_job_agent.runner_2.id
40+
config = { delaySeconds = "10", message = "Test runner job agent", status = "successful" }
41+
selector = "true"
42+
}
43+
}

0 commit comments

Comments
 (0)