Skip to content

Commit a2cd7ae

Browse files
authored
fix(stepfunctions): disabling logging still requires LogGroup (#30816)
### Issue # (if applicable) Closes #30814. ### Reason for this change To disable logging on a StateMachine (with logging enabled), we should specify `LogLevel.OFF` to `LogOptions.level`. But cannot remove the LogGroup because `LogOptions.destination` is required. ``` ts new sfn.StateMachine(this, 'StateMachine', { definitionBody: ..., logs: { level: sfn.LogLevel.OFF } // allow to disable logging }); ``` ### Description of changes - Make `LogOptions.destination` optional. - Validate `LogOptions.destination` is present when `LogOptions.level` is not `OFF`. ### Description of how you validated changes Unit and integ tests that verify `LogOptions.destination` is opitional when `LogOptions.level` is `OFF` and throw an exception otherwise. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7be4456 commit a2cd7ae

File tree

11 files changed

+828
-19
lines changed

11 files changed

+828
-19
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-logging.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-logging.js.snapshot/IntegTestDefaultTestDeployAssertE3E7D2A4.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-logging.js.snapshot/aws-stepfunctions-integ.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
{
2+
"Resources": {
3+
"LogGroupF5B46931": {
4+
"Type": "AWS::Logs::LogGroup",
5+
"Properties": {
6+
"RetentionInDays": 731
7+
},
8+
"UpdateReplacePolicy": "Delete",
9+
"DeletionPolicy": "Delete"
10+
},
11+
"StateMachineWithLoggingALLRole0984788E": {
12+
"Type": "AWS::IAM::Role",
13+
"Properties": {
14+
"AssumeRolePolicyDocument": {
15+
"Statement": [
16+
{
17+
"Action": "sts:AssumeRole",
18+
"Effect": "Allow",
19+
"Principal": {
20+
"Service": "states.amazonaws.com"
21+
}
22+
}
23+
],
24+
"Version": "2012-10-17"
25+
}
26+
}
27+
},
28+
"StateMachineWithLoggingALLRoleDefaultPolicy12972CD9": {
29+
"Type": "AWS::IAM::Policy",
30+
"Properties": {
31+
"PolicyDocument": {
32+
"Statement": [
33+
{
34+
"Action": [
35+
"logs:CreateLogDelivery",
36+
"logs:DeleteLogDelivery",
37+
"logs:DescribeLogGroups",
38+
"logs:DescribeResourcePolicies",
39+
"logs:GetLogDelivery",
40+
"logs:ListLogDeliveries",
41+
"logs:PutResourcePolicy",
42+
"logs:UpdateLogDelivery"
43+
],
44+
"Effect": "Allow",
45+
"Resource": "*"
46+
}
47+
],
48+
"Version": "2012-10-17"
49+
},
50+
"PolicyName": "StateMachineWithLoggingALLRoleDefaultPolicy12972CD9",
51+
"Roles": [
52+
{
53+
"Ref": "StateMachineWithLoggingALLRole0984788E"
54+
}
55+
]
56+
}
57+
},
58+
"StateMachineWithLoggingALL687B0F0F": {
59+
"Type": "AWS::StepFunctions::StateMachine",
60+
"Properties": {
61+
"DefinitionString": "{\"StartAt\":\"Pass\",\"States\":{\"Pass\":{\"Type\":\"Pass\",\"End\":true}}}",
62+
"LoggingConfiguration": {
63+
"Destinations": [
64+
{
65+
"CloudWatchLogsLogGroup": {
66+
"LogGroupArn": {
67+
"Fn::GetAtt": [
68+
"LogGroupF5B46931",
69+
"Arn"
70+
]
71+
}
72+
}
73+
}
74+
],
75+
"Level": "ALL"
76+
},
77+
"RoleArn": {
78+
"Fn::GetAtt": [
79+
"StateMachineWithLoggingALLRole0984788E",
80+
"Arn"
81+
]
82+
}
83+
},
84+
"DependsOn": [
85+
"StateMachineWithLoggingALLRoleDefaultPolicy12972CD9",
86+
"StateMachineWithLoggingALLRole0984788E"
87+
],
88+
"UpdateReplacePolicy": "Delete",
89+
"DeletionPolicy": "Delete"
90+
},
91+
"StateMachineWithLoggingOFFRole726E8117": {
92+
"Type": "AWS::IAM::Role",
93+
"Properties": {
94+
"AssumeRolePolicyDocument": {
95+
"Statement": [
96+
{
97+
"Action": "sts:AssumeRole",
98+
"Effect": "Allow",
99+
"Principal": {
100+
"Service": "states.amazonaws.com"
101+
}
102+
}
103+
],
104+
"Version": "2012-10-17"
105+
}
106+
}
107+
},
108+
"StateMachineWithLoggingOFFF82B7349": {
109+
"Type": "AWS::StepFunctions::StateMachine",
110+
"Properties": {
111+
"DefinitionString": "{\"StartAt\":\"Pass\",\"States\":{\"Pass\":{\"Type\":\"Pass\",\"End\":true}}}",
112+
"LoggingConfiguration": {
113+
"Level": "OFF"
114+
},
115+
"RoleArn": {
116+
"Fn::GetAtt": [
117+
"StateMachineWithLoggingOFFRole726E8117",
118+
"Arn"
119+
]
120+
}
121+
},
122+
"DependsOn": [
123+
"StateMachineWithLoggingOFFRole726E8117"
124+
],
125+
"UpdateReplacePolicy": "Delete",
126+
"DeletionPolicy": "Delete"
127+
}
128+
},
129+
"Parameters": {
130+
"BootstrapVersion": {
131+
"Type": "AWS::SSM::Parameter::Value<String>",
132+
"Default": "/cdk-bootstrap/hnb659fds/version",
133+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
134+
}
135+
},
136+
"Rules": {
137+
"CheckBootstrapVersion": {
138+
"Assertions": [
139+
{
140+
"Assert": {
141+
"Fn::Not": [
142+
{
143+
"Fn::Contains": [
144+
[
145+
"1",
146+
"2",
147+
"3",
148+
"4",
149+
"5"
150+
],
151+
{
152+
"Ref": "BootstrapVersion"
153+
}
154+
]
155+
}
156+
]
157+
},
158+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
159+
}
160+
]
161+
}
162+
}
163+
}

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-logging.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.state-machine-logging.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)