Skip to content

Commit 9f75830

Browse files
committed
New action docs
1 parent 6f22b9c commit 9f75830

File tree

1 file changed

+237
-0
lines changed

1 file changed

+237
-0
lines changed
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
---
2+
subcategory: "SFN (Step Functions)"
3+
layout: "aws"
4+
page_title: "AWS: aws_sfn_start_execution"
5+
description: |-
6+
Starts a Step Functions state machine execution with the specified input data.
7+
---
8+
9+
# Action: aws_sfn_start_execution
10+
11+
~> **Note:** `aws_sfn_start_execution` is in beta. Its interface and behavior may change as the feature evolves, and breaking changes are possible. It is offered as a technical preview without compatibility guarantees until Terraform 1.14 is generally available.
12+
13+
Starts a Step Functions state machine execution with the specified input data. This action allows for imperative execution of state machines with full control over execution parameters.
14+
15+
For information about AWS Step Functions, see the [AWS Step Functions Developer Guide](https://docs.aws.amazon.com/step-functions/latest/dg/). For specific information about starting executions, see the [StartExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html) page in the AWS Step Functions API Reference.
16+
17+
~> **Note:** For `STANDARD` workflows, executions with the same name and input are idempotent. For `EXPRESS` workflows, each execution is unique regardless of name and input.
18+
19+
## Example Usage
20+
21+
### Basic Usage
22+
23+
```terraform
24+
resource "aws_sfn_state_machine" "example" {
25+
name = "example-state-machine"
26+
role_arn = aws_iam_role.sfn.arn
27+
28+
definition = jsonencode({
29+
Comment = "A simple minimal example"
30+
StartAt = "Hello"
31+
States = {
32+
Hello = {
33+
Type = "Pass"
34+
Result = "Hello World!"
35+
End = true
36+
}
37+
}
38+
})
39+
}
40+
41+
action "aws_sfn_start_execution" "example" {
42+
config {
43+
state_machine_arn = aws_sfn_state_machine.example.arn
44+
input = jsonencode({
45+
user_id = "12345"
46+
action = "process"
47+
})
48+
}
49+
}
50+
51+
resource "terraform_data" "example" {
52+
input = "trigger-execution"
53+
54+
lifecycle {
55+
action_trigger {
56+
events = [before_create, before_update]
57+
actions = [action.aws_sfn_start_execution.example]
58+
}
59+
}
60+
}
61+
```
62+
63+
### Named Execution
64+
65+
```terraform
66+
action "aws_sfn_start_execution" "named" {
67+
config {
68+
state_machine_arn = aws_sfn_state_machine.processor.arn
69+
name = "deployment-${var.deployment_id}"
70+
input = jsonencode({
71+
deployment_id = var.deployment_id
72+
environment = var.environment
73+
})
74+
}
75+
}
76+
```
77+
78+
### Execution with Version
79+
80+
```terraform
81+
action "aws_sfn_start_execution" "versioned" {
82+
config {
83+
state_machine_arn = "${aws_sfn_state_machine.example.arn}:${aws_sfn_state_machine.example.version_number}"
84+
input = jsonencode({
85+
version = "v2"
86+
config = var.processing_config
87+
})
88+
}
89+
}
90+
```
91+
92+
### Execution with Alias
93+
94+
```terraform
95+
resource "aws_sfn_alias" "prod" {
96+
name = "PROD"
97+
state_machine_arn = aws_sfn_state_machine.example.arn
98+
routing_configuration {
99+
state_machine_version_weight {
100+
state_machine_version_arn = aws_sfn_state_machine.example.arn
101+
weight = 100
102+
}
103+
}
104+
}
105+
106+
action "aws_sfn_start_execution" "production" {
107+
config {
108+
state_machine_arn = aws_sfn_alias.prod.arn
109+
input = jsonencode({
110+
environment = "production"
111+
batch_size = 1000
112+
})
113+
}
114+
}
115+
```
116+
117+
### X-Ray Tracing
118+
119+
```terraform
120+
action "aws_sfn_start_execution" "traced" {
121+
config {
122+
state_machine_arn = aws_sfn_state_machine.example.arn
123+
trace_header = "Root=1-${formatdate("YYYYMMDD", timestamp())}-${substr(uuid(), 0, 24)}"
124+
input = jsonencode({
125+
trace_id = "custom-trace-${timestamp()}"
126+
data = var.processing_data
127+
})
128+
}
129+
}
130+
```
131+
132+
### CI/CD Pipeline Integration
133+
134+
Use this action in your deployment pipeline to trigger post-deployment workflows:
135+
136+
```terraform
137+
resource "terraform_data" "deploy_complete" {
138+
input = local.deployment_id
139+
140+
lifecycle {
141+
action_trigger {
142+
events = [before_create, before_update]
143+
actions = [action.aws_sfn_start_execution.post_deploy]
144+
}
145+
}
146+
147+
depends_on = [aws_lambda_function.processors]
148+
}
149+
150+
action "aws_sfn_start_execution" "post_deploy" {
151+
config {
152+
state_machine_arn = aws_sfn_state_machine.data_pipeline.arn
153+
name = "post-deploy-${local.deployment_id}"
154+
input = jsonencode({
155+
deployment_id = local.deployment_id
156+
environment = var.environment
157+
resources = {
158+
lambda_functions = [for f in aws_lambda_function.processors : f.arn]
159+
s3_bucket = aws_s3_bucket.data.bucket
160+
}
161+
})
162+
}
163+
}
164+
```
165+
166+
### Environment-Specific Processing
167+
168+
```terraform
169+
locals {
170+
execution_config = var.environment == "production" ? {
171+
batch_size = 1000
172+
max_retries = 3
173+
timeout_hours = 24
174+
} : {
175+
batch_size = 100
176+
max_retries = 1
177+
timeout_hours = 2
178+
}
179+
}
180+
181+
action "aws_sfn_start_execution" "batch_process" {
182+
config {
183+
state_machine_arn = aws_sfn_state_machine.batch_processor.arn
184+
input = jsonencode(merge(local.execution_config, {
185+
data_source = var.data_source
186+
output_path = var.output_path
187+
}))
188+
}
189+
}
190+
```
191+
192+
### Complex Workflow Orchestration
193+
194+
```terraform
195+
action "aws_sfn_start_execution" "orchestrator" {
196+
config {
197+
state_machine_arn = aws_sfn_state_machine.orchestrator.arn
198+
input = jsonencode({
199+
workflow = {
200+
id = "workflow-${timestamp()}"
201+
type = "data-processing"
202+
steps = var.workflow_steps
203+
}
204+
resources = {
205+
compute = {
206+
lambda_functions = [for f in aws_lambda_function.workers : f.arn]
207+
ecs_cluster = aws_ecs_cluster.processing.arn
208+
}
209+
storage = {
210+
input_bucket = aws_s3_bucket.input.bucket
211+
output_bucket = aws_s3_bucket.output.bucket
212+
temp_bucket = aws_s3_bucket.temp.bucket
213+
}
214+
messaging = {
215+
success_topic = aws_sns_topic.success.arn
216+
error_topic = aws_sns_topic.errors.arn
217+
}
218+
}
219+
metadata = {
220+
created_by = "terraform"
221+
environment = var.environment
222+
version = var.app_version
223+
tags = var.execution_tags
224+
}
225+
})
226+
}
227+
}
228+
```
229+
230+
## Argument Reference
231+
232+
This action supports the following arguments:
233+
234+
* `input` - (Optional) JSON input data for the execution. Must be valid JSON. Defaults to `{}` if not specified. The input size limit is 256 KB.
235+
* `name` - (Optional) Name of the execution. Must be unique within the account/region/state machine for 90 days. If not provided, Step Functions automatically generates a UUID. Names must not contain whitespace, brackets, wildcards, or special characters.
236+
* `state_machine_arn` - (Required) ARN of the state machine to execute. Can be an unqualified ARN, version-qualified ARN (e.g., `arn:aws:states:region:account:stateMachine:name:version`), or alias-qualified ARN (e.g., `arn:aws:states:region:account:stateMachine:name:alias`).
237+
* `trace_header` - (Optional) AWS X-Ray trace header for distributed tracing. Used to correlate execution traces across services.

0 commit comments

Comments
 (0)