Skip to content

Commit 00b8a37

Browse files
author
Connor Robertson
authored
Adding InputTransformer Property (#3338)
1 parent 0900f2b commit 00b8a37

8 files changed

+579
-0
lines changed

samtranslator/internal/schema_source/aws_serverless_statemachine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class EventBridgeRuleEventProperties(BaseModel):
119119
RetryPolicy: Optional[PassThroughProp] = eventbridgeruleeventproperties("RetryPolicy")
120120
Target: Optional[EventBridgeRuleTarget] = eventbridgeruleeventproperties("Target")
121121
RuleName: Optional[PassThroughProp] = eventbridgeruleeventproperties("RuleName")
122+
InputTransformer: Optional[PassThroughProp] # TODO: add docs
122123

123124

124125
class EventBridgeRuleEvent(BaseModel):

samtranslator/model/stepfunctions/events.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class CloudWatchEvent(EventSource):
193193
"RetryPolicy": PropertyType(False, IS_DICT),
194194
"State": PropertyType(False, IS_STR),
195195
"Target": Property(False, IS_DICT),
196+
"InputTransformer": PropertyType(False, IS_DICT),
196197
}
197198

198199
EventBusName: Optional[PassThrough]
@@ -204,6 +205,7 @@ class CloudWatchEvent(EventSource):
204205
RetryPolicy: Optional[PassThrough]
205206
State: Optional[PassThrough]
206207
Target: Optional[PassThrough]
208+
InputTransformer: Optional[PassThrough]
207209

208210
@cw_timer(prefix=SFN_EVETSOURCE_METRIC_PREFIX)
209211
def to_cloudformation(self, resource, **kwargs): # type: ignore[no-untyped-def]
@@ -273,6 +275,9 @@ def _construct_target(self, resource, role, dead_letter_queue_arn=None): # type
273275
if self.RetryPolicy is not None:
274276
target["RetryPolicy"] = self.RetryPolicy
275277

278+
if self.InputTransformer is not None:
279+
target["InputTransformer"] = self.InputTransformer
280+
276281
return target
277282

278283

samtranslator/schema/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254477,6 +254477,9 @@
254477254477
"markdownDescription": "When you don't want to pass the entire matched event to the target, use the `InputPath` property to describe which part of the event to pass\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`InputPath`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath) property of an `AWS::Events::Rule Target` resource\\.",
254478254478
"title": "InputPath"
254479254479
},
254480+
"InputTransformer": {
254481+
"$ref": "#/definitions/PassThroughProp"
254482+
},
254480254483
"Pattern": {
254481254484
"allOf": [
254482254485
{

schema_source/sam.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7660,6 +7660,9 @@
76607660
"markdownDescription": "When you don't want to pass the entire matched event to the target, use the `InputPath` property to describe which part of the event to pass\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`InputPath`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath) property of an `AWS::Events::Rule Target` resource\\.",
76617661
"title": "InputPath"
76627662
},
7663+
"InputTransformer": {
7664+
"$ref": "#/definitions/PassThroughProp"
7665+
},
76637666
"Pattern": {
76647667
"allOf": [
76657668
{
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Resources:
2+
StateMachine:
3+
Type: AWS::Serverless::StateMachine
4+
Properties:
5+
Name: !Sub ${AWS::StackName}-StateMachine
6+
Definition:
7+
Comment: A Hello World example of the Amazon States Language using Pass states
8+
StartAt: Hello
9+
States:
10+
Hello:
11+
Type: Pass
12+
Result: Hello
13+
Next: World
14+
World:
15+
Type: Pass
16+
Result: World
17+
End: true
18+
Policies:
19+
- Version: '2012-10-17'
20+
Statement:
21+
- Effect: Deny
22+
Action: '*'
23+
Resource: '*'
24+
Events:
25+
EventBridgeEvent:
26+
Type: EventBridgeRule
27+
Properties:
28+
EventBusName: default
29+
Pattern:
30+
source:
31+
- aws.s3
32+
detail-type:
33+
- Object Created
34+
detail:
35+
bucket:
36+
name:
37+
- abc
38+
object:
39+
key:
40+
- xyz
41+
InputTransformer:
42+
InputPathsMap:
43+
bucket: $.detail.bucket.name
44+
key: $.detail.object.key
45+
InputTemplate: '{"bucket": <bucket>, "key": <key>}'
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
{
2+
"Resources": {
3+
"StateMachine": {
4+
"Properties": {
5+
"DefinitionString": {
6+
"Fn::Join": [
7+
"\n",
8+
[
9+
"{",
10+
" \"Comment\": \"A Hello World example of the Amazon States Language using Pass states\",",
11+
" \"StartAt\": \"Hello\",",
12+
" \"States\": {",
13+
" \"Hello\": {",
14+
" \"Next\": \"World\",",
15+
" \"Result\": \"Hello\",",
16+
" \"Type\": \"Pass\"",
17+
" },",
18+
" \"World\": {",
19+
" \"End\": true,",
20+
" \"Result\": \"World\",",
21+
" \"Type\": \"Pass\"",
22+
" }",
23+
" }",
24+
"}"
25+
]
26+
]
27+
},
28+
"RoleArn": {
29+
"Fn::GetAtt": [
30+
"StateMachineRole",
31+
"Arn"
32+
]
33+
},
34+
"StateMachineName": {
35+
"Fn::Sub": "${AWS::StackName}-StateMachine"
36+
},
37+
"Tags": [
38+
{
39+
"Key": "stateMachine:createdBy",
40+
"Value": "SAM"
41+
}
42+
]
43+
},
44+
"Type": "AWS::StepFunctions::StateMachine"
45+
},
46+
"StateMachineEventBridgeEvent": {
47+
"Properties": {
48+
"EventBusName": "default",
49+
"EventPattern": {
50+
"detail": {
51+
"bucket": {
52+
"name": [
53+
"abc"
54+
]
55+
},
56+
"object": {
57+
"key": [
58+
"xyz"
59+
]
60+
}
61+
},
62+
"detail-type": [
63+
"Object Created"
64+
],
65+
"source": [
66+
"aws.s3"
67+
]
68+
},
69+
"Targets": [
70+
{
71+
"Arn": {
72+
"Ref": "StateMachine"
73+
},
74+
"Id": "StateMachineEventBridgeEventStepFunctionsTarget",
75+
"InputTransformer": {
76+
"InputPathsMap": {
77+
"bucket": "$.detail.bucket.name",
78+
"key": "$.detail.object.key"
79+
},
80+
"InputTemplate": "{\"bucket\": <bucket>, \"key\": <key>}"
81+
},
82+
"RoleArn": {
83+
"Fn::GetAtt": [
84+
"StateMachineEventBridgeEventRole",
85+
"Arn"
86+
]
87+
}
88+
}
89+
]
90+
},
91+
"Type": "AWS::Events::Rule"
92+
},
93+
"StateMachineEventBridgeEventRole": {
94+
"Properties": {
95+
"AssumeRolePolicyDocument": {
96+
"Statement": [
97+
{
98+
"Action": [
99+
"sts:AssumeRole"
100+
],
101+
"Effect": "Allow",
102+
"Principal": {
103+
"Service": [
104+
"events.amazonaws.com"
105+
]
106+
}
107+
}
108+
],
109+
"Version": "2012-10-17"
110+
},
111+
"Policies": [
112+
{
113+
"PolicyDocument": {
114+
"Statement": [
115+
{
116+
"Action": "states:StartExecution",
117+
"Effect": "Allow",
118+
"Resource": {
119+
"Ref": "StateMachine"
120+
}
121+
}
122+
]
123+
},
124+
"PolicyName": "StateMachineEventBridgeEventRoleStartExecutionPolicy"
125+
}
126+
]
127+
},
128+
"Type": "AWS::IAM::Role"
129+
},
130+
"StateMachineRole": {
131+
"Properties": {
132+
"AssumeRolePolicyDocument": {
133+
"Statement": [
134+
{
135+
"Action": [
136+
"sts:AssumeRole"
137+
],
138+
"Effect": "Allow",
139+
"Principal": {
140+
"Service": [
141+
"states.amazonaws.com"
142+
]
143+
}
144+
}
145+
],
146+
"Version": "2012-10-17"
147+
},
148+
"ManagedPolicyArns": [],
149+
"Policies": [
150+
{
151+
"PolicyDocument": {
152+
"Statement": [
153+
{
154+
"Action": "*",
155+
"Effect": "Deny",
156+
"Resource": "*"
157+
}
158+
],
159+
"Version": "2012-10-17"
160+
},
161+
"PolicyName": "StateMachineRolePolicy0"
162+
}
163+
],
164+
"Tags": [
165+
{
166+
"Key": "stateMachine:createdBy",
167+
"Value": "SAM"
168+
}
169+
]
170+
},
171+
"Type": "AWS::IAM::Role"
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)