Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit ebd04d5

Browse files
committed
Add documentation examples for templated steps
1 parent 75346e7 commit ebd04d5

File tree

9 files changed

+78
-60
lines changed

9 files changed

+78
-60
lines changed

docs/resources/process_templated_child_step.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@ resource "octopusdeploy_step_template" "my_script" {
4646
4747
parameters = [
4848
{
49-
name = "Parameter.One"
49+
name = "Parameter.One"
5050
id = "10001000-0000-0000-0000-100010001001"
51-
label = "First Parameter"
51+
label = "First Parameter"
5252
default_value = "default-value-one"
5353
display_settings = {
5454
"Octopus.ControlType" : "SingleLineText"
5555
}
5656
},
5757
{
58-
name = "Parameter.Two"
58+
name = "Parameter.Two"
5959
id = "10001000-0000-0000-0000-100010001002"
60-
label = "Second Parameter"
60+
label = "Second Parameter"
6161
display_settings = {
62-
"Octopus.ControlType" : "SingleLineText"
62+
"Octopus.ControlType": "SingleLineText"
6363
}
6464
},
6565
]
6666
6767
properties = {
68-
"Octopus.Action.Script.ScriptBody" : "echo '1.#{Parameter.One} ... 2.#{Parameter.Two} ...'"
69-
"Octopus.Action.Script.ScriptSource" : "Inline"
70-
"Octopus.Action.Script.Syntax" : "Bash"
68+
"Octopus.Action.Script.ScriptBody": "echo '1.#{Parameter.One} ... 2.#{Parameter.Two} ...'"
69+
"Octopus.Action.Script.ScriptSource": "Inline"
70+
"Octopus.Action.Script.Syntax": "Bash"
7171
}
7272
}
7373
@@ -86,11 +86,29 @@ resource "octopusdeploy_process" "example" {
8686
project_id = octopusdeploy_project.example.id
8787
}
8888
89+
resource "octopusdeploy_process_step" "parent" {
90+
process_id = octopusdeploy_process.app.id
91+
name = "Parent Step"
92+
properties = {
93+
"Octopus.Action.MaxParallelism" = "2"
94+
"Octopus.Action.TargetRoles" = "azure-one"
95+
}
96+
type = "Octopus.Script"
97+
execution_properties = {
98+
"Octopus.Action.RunOnServer" = "True"
99+
"Octopus.Action.Script.ScriptSource" = "Inline"
100+
"Octopus.Action.Script.Syntax" = "PowerShell"
101+
"Octopus.Action.Script.ScriptBody" = <<-EOT
102+
Write-Host "Parent Step: #{My.Variable}"
103+
EOT
104+
}
105+
}
89106
90-
# Run templated script step
91-
resource "octopusdeploy_templated_process_step" "script" {
107+
# Templated script child step
108+
resource "octopusdeploy_process_templated_child_step" "script" {
92109
process_id = octopusdeploy_process.example.id
93-
name = "Step 3"
110+
parent_id = octopusdeploy_process_step.parent.id
111+
name = "Templated Child Step"
94112
template_id = octopusdeploy_step_template.my_script.id
95113
template_version = octopusdeploy_step_template.my_script.version
96114
@@ -190,5 +208,5 @@ Read-Only:
190208
Import is supported using the following syntax:
191209

192210
```shell
193-
terraform import [options] octopusdeploy_process_templated_step.<name> "<process-id>:<step-id>"
211+
terraform import [options] octopusdeploy_process_templated_child_step.<name> "<process-id>:<parent-step-id>:<child-step-id>"
194212
```

docs/resources/process_templated_step.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ description: |-
1010
This resource manages a single step of a Runbook or Deployment Process which based on existing custom step template
1111

1212
### Remarks
13-
A Step is the building block of a Deployment or Runbook Process.
13+
A Templated Step is the step of a Deployment or Runbook Process which based on existing custom step template
1414

15-
When there are multiple Steps in a Process, we strongly recommend adding a `octopusdeploy_process_step_order` resource to pin the step order. If you later need to change the order of steps in your process, or insert a new step within an existing process, you'll need the Step Order defined first. Without an explicit Step Order, Steps will be added to the process in the order they're applied by Terraform - this is usually the order they appear in your HCL, but is not guaranteed to be deterministic.
16-
17-
This resource also contains a concept that doesn't exist in the Octopus Deploy domain model: `properties` vs `execution_properties`:
18-
19-
* `properties` are the inputs to control behaviour of the step within the process as whole
20-
* `execution_properties` are the controls for how and what will be executed when step runs
15+
This resource expose only attributes which can be controlled by the consumer of a template. To avoid 'state drift' templated step divide template parameters into two attributes 'parameters' and 'unmanaged_parameters':
16+
* `parameters` are template parameters configured by the practitioner
17+
* `unmanaged_parameters` is readonly collection of template parameters not configured by the practitioner (usually parameters with default value)
2118

2219
## Example Usage
2320

@@ -82,26 +79,20 @@ resource "octopusdeploy_project" "example" {
8279
name = "Example"
8380
}
8481
85-
resource "octopusdeploy_channel" "example" {
86-
name = "Example Channel (OK to Delete)"
87-
project_id = octopusdeploy_project.example.id
88-
}
89-
9082
resource "octopusdeploy_process" "example" {
9183
project_id = octopusdeploy_project.example.id
9284
}
9385
94-
95-
# Run templated script step
86+
# Templated script step
9687
resource "octopusdeploy_templated_process_step" "script" {
9788
process_id = octopusdeploy_process.example.id
98-
name = "Step 3"
89+
name = "Templated Step"
9990
template_id = octopusdeploy_step_template.my_script.id
10091
template_version = octopusdeploy_step_template.my_script.version
10192
10293
# Parameter's default value is used when not provided in configuration
10394
parameters = {
104-
"Parameter.Two" = "my-second-value"
95+
"Parameter.Two" = "my-example-value"
10596
}
10697
10798
execution_properties = {
@@ -197,5 +188,5 @@ Read-Only:
197188
Import is supported using the following syntax:
198189

199190
```shell
200-
terraform import [options] octopusdeploy_process_templated_child_step.<name> "<process-id>:<parent-step-id>:<child-step-id>"
191+
terraform import [options] octopusdeploy_process_templated_step.<name> "<process-id>:<step-id>"
201192
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
terraform import [options] octopusdeploy_process_templated_step.<name> "<process-id>:<step-id>"
1+
terraform import [options] octopusdeploy_process_templated_child_step.<name> "<process-id>:<parent-step-id>:<child-step-id>"

examples/resources/octopusdeploy_process_templated_child_step/resource.tf

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@ resource "octopusdeploy_step_template" "my_script" {
2727

2828
parameters = [
2929
{
30-
name = "Parameter.One"
30+
name = "Parameter.One"
3131
id = "10001000-0000-0000-0000-100010001001"
32-
label = "First Parameter"
32+
label = "First Parameter"
3333
default_value = "default-value-one"
3434
display_settings = {
3535
"Octopus.ControlType" : "SingleLineText"
3636
}
3737
},
3838
{
39-
name = "Parameter.Two"
39+
name = "Parameter.Two"
4040
id = "10001000-0000-0000-0000-100010001002"
41-
label = "Second Parameter"
41+
label = "Second Parameter"
4242
display_settings = {
43-
"Octopus.ControlType" : "SingleLineText"
43+
"Octopus.ControlType": "SingleLineText"
4444
}
4545
},
4646
]
4747

4848
properties = {
49-
"Octopus.Action.Script.ScriptBody" : "echo '1.#{Parameter.One} ... 2.#{Parameter.Two} ...'"
50-
"Octopus.Action.Script.ScriptSource" : "Inline"
51-
"Octopus.Action.Script.Syntax" : "Bash"
49+
"Octopus.Action.Script.ScriptBody": "echo '1.#{Parameter.One} ... 2.#{Parameter.Two} ...'"
50+
"Octopus.Action.Script.ScriptSource": "Inline"
51+
"Octopus.Action.Script.Syntax": "Bash"
5252
}
5353
}
5454

@@ -67,11 +67,29 @@ resource "octopusdeploy_process" "example" {
6767
project_id = octopusdeploy_project.example.id
6868
}
6969

70+
resource "octopusdeploy_process_step" "parent" {
71+
process_id = octopusdeploy_process.app.id
72+
name = "Parent Step"
73+
properties = {
74+
"Octopus.Action.MaxParallelism" = "2"
75+
"Octopus.Action.TargetRoles" = "azure-one"
76+
}
77+
type = "Octopus.Script"
78+
execution_properties = {
79+
"Octopus.Action.RunOnServer" = "True"
80+
"Octopus.Action.Script.ScriptSource" = "Inline"
81+
"Octopus.Action.Script.Syntax" = "PowerShell"
82+
"Octopus.Action.Script.ScriptBody" = <<-EOT
83+
Write-Host "Parent Step: #{My.Variable}"
84+
EOT
85+
}
86+
}
7087

71-
# Run templated script step
72-
resource "octopusdeploy_templated_process_step" "script" {
88+
# Templated script child step
89+
resource "octopusdeploy_process_templated_child_step" "script" {
7390
process_id = octopusdeploy_process.example.id
74-
name = "Step 3"
91+
parent_id = octopusdeploy_process_step.parent.id
92+
name = "Templated Child Step"
7593
template_id = octopusdeploy_step_template.my_script.id
7694
template_version = octopusdeploy_step_template.my_script.version
7795

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
terraform import [options] octopusdeploy_process_templated_child_step.<name> "<process-id>:<parent-step-id>:<child-step-id>"
1+
terraform import [options] octopusdeploy_process_templated_step.<name> "<process-id>:<step-id>"

examples/resources/octopusdeploy_process_templated_step/resource.tf

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,20 @@ resource "octopusdeploy_project" "example" {
5858
name = "Example"
5959
}
6060

61-
resource "octopusdeploy_channel" "example" {
62-
name = "Example Channel (OK to Delete)"
63-
project_id = octopusdeploy_project.example.id
64-
}
65-
6661
resource "octopusdeploy_process" "example" {
6762
project_id = octopusdeploy_project.example.id
6863
}
6964

70-
71-
# Run templated script step
65+
# Templated script step
7266
resource "octopusdeploy_templated_process_step" "script" {
7367
process_id = octopusdeploy_process.example.id
74-
name = "Step 3"
68+
name = "Templated Step"
7569
template_id = octopusdeploy_step_template.my_script.id
7670
template_version = octopusdeploy_step_template.my_script.version
7771

7872
# Parameter's default value is used when not provided in configuration
7973
parameters = {
80-
"Parameter.Two" = "my-second-value"
74+
"Parameter.Two" = "my-example-value"
8175
}
8276

8377
execution_properties = {

octopusdeploy_framework/schemas/process_templated_child_step.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (p ProcessTemplatedChildStepSchema) GetResourceSchema() resourceSchema.Sche
136136
DefaultEmpty().
137137
Build(),
138138
"unmanaged_parameters": util.ResourceMap(types.StringType).
139-
Description("Template parameters not configured by the practitioner.").
139+
Description("Template parameters not configured by the practitioner (usually parameters with default value).").
140140
Computed().
141141
Build(),
142142
"template_properties": util.ResourceMap(types.StringType).

octopusdeploy_framework/schemas/process_templated_step.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (p ProcessTemplatedStepSchema) GetResourceSchema() resourceSchema.Schema {
154154
DefaultEmpty().
155155
Build(),
156156
"unmanaged_parameters": util.ResourceMap(types.StringType).
157-
Description("Template parameters not configured by the practitioner.").
157+
Description("Template parameters not configured by the practitioner (usually parameters with default value).").
158158
Computed().
159159
Build(),
160160
"template_properties": util.ResourceMap(types.StringType).

templates/resources/process_templated_step.md.tmpl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ description: |-
1010
{{ .Description | trimspace }}
1111

1212
### Remarks
13-
A Step is the building block of a Deployment or Runbook Process.
13+
A Templated Step is the step of a Deployment or Runbook Process which based on existing custom step template
1414

15-
When there are multiple Steps in a Process, we strongly recommend adding a `octopusdeploy_process_step_order` resource to pin the step order. If you later need to change the order of steps in your process, or insert a new step within an existing process, you'll need the Step Order defined first. Without an explicit Step Order, Steps will be added to the process in the order they're applied by Terraform - this is usually the order they appear in your HCL, but is not guaranteed to be deterministic.
16-
17-
This resource also contains a concept that doesn't exist in the Octopus Deploy domain model: `properties` vs `execution_properties`:
18-
19-
* `properties` are the inputs to control behaviour of the step within the process as whole
20-
* `execution_properties` are the controls for how and what will be executed when step runs
15+
This resource expose only attributes which can be controlled by the consumer of a template. To avoid 'state drift' templated step divide template parameters into two attributes 'parameters' and 'unmanaged_parameters':
16+
* `parameters` are template parameters configured by the practitioner
17+
* `unmanaged_parameters` is readonly collection of template parameters not configured by the practitioner (usually parameters with default value)
2118

2219
## Example Usage
2320

0 commit comments

Comments
 (0)