Step Functions Tracing
Level : Warning
Initial version : 0.1.3
cfn-lint : WS5000
tflint : aws_sfn_state_machine_tracing
AWS Step Functions can emit traces to AWS X-Ray, which enables visualizing service maps for faster troubleshooting.
Why is this a warning?
You might use third party solutions for monitoring serverless applications. If this is the case, enabling tracing for Step Functions might be optional. Refer to the documentation of your monitoring solutions to see if you should enable AWS X-Ray tracing or not.
Implementations
CDK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 import { Function } from '@aws-cdk/aws-lambda' ;
import { StateMachine } from '@aws-cdk/aws-stepfunctions' ;
import * as tasks from '@aws-cdk/aws-stepfunctions-
export class MyStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const myFunction = new Function(
scope, ' MyFunction ',
{
code: Code.fromAsset(' src / hello / '),
handler: ' main . handler ',
runtime: Runtime.PYTHON_3_8,
}
);
const myJob = tasks.LambdaInvoke(
scope, ' MyJob ',
{
lambdaFunction: myFunction,
},
);
const myStateMachine = new StateMachine(
scope, ' MyStateMachine ' ,
{
definition : myJob ,
// Enable tracing on Step Functions
tracingEnabled : true ,
}
);
}
}
CloudFormation (JSON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 {
"Resources" : {
"StateMachine" : {
"Type" : "AWS::StepFunctions::StateMachine" ,
"Properties" : {
"DefinitionString" : "{ \"StartAt\": \"HelloWorld\", \"States\": { \"HelloWorld\": { \"Type\": \"Task\", \"Resource\": \"arn:aws:lambda:us-east-1:111122223333:function:HelloFunction\", \"End\": \"true\" }}}" ,
"RoleArn" : "arn:aws:iam::111122223333:role/service-role/StatesExecutionRole" ,
// Enable active tracing for Step Functions
"TracingConfiguration" : {
"Enabled" : true
}
}
}
}
}
CloudFormation YAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 Resources :
StateMachine :
Type : AWS::StepFunctions::StateMachine
Properties :
DefinitionString : |
{
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:111122223333:function:HelloFunction",
"End": "true"
}
}
}
RoleArn : arn:aws:iam::111122223333:role/service-role/StatesExecutionRole
# Enable active tracing for Step Functions
TracingConfiguration :
Enabled : true
Serverless Framework
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 resources :
Resources :
StateMachine :
Type : AWS::StepFunctions::StateMachine
Properties :
DefinitionString : |
{
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:111122223333:function:HelloFunction",
"End": "true"
}
}
}
RoleArn : arn:aws:iam::111122223333:role/service-role/StatesExecutionRole
# Enable active tracing for Step Functions
TracingConfiguration :
Enabled : true
Terraform
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 resource "aws_sfn_state_machine" "this" {
name = "my-state-machine"
role_arn = "arn:aws:iam::111122223333:role/my-state-machine-role"
definition = << EOF
{
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:111122223333:function:HelloFunction",
"End": "true"
}
}
}
EOF
# Enable active tracing for Step Functions
tracing_configuration {
enabled = true
}
}
See also