@@ -172,13 +172,15 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P
172
172
# `Type` property is for sam to attach the right policies
173
173
destination_type = on_failure .get ("Type" )
174
174
175
- # SAM attaches the policies for SQS or SNS only if 'Type' is given
175
+ # SAM attaches the policies for SQS, SNS or S3 only if 'Type' is given
176
176
if destination_type :
177
177
# delete this field as its used internally for SAM to determine the policy
178
178
del on_failure ["Type" ]
179
- # the values 'SQS' and 'SNS' are allowed. No intrinsics are allowed
180
- if destination_type not in ["SQS" , "SNS" ]:
181
- raise InvalidEventException (self .logical_id , "The only valid values for 'Type' are 'SQS' and 'SNS'" )
179
+ # the values 'SQS', 'SNS', and 'S3' are allowed. No intrinsics are allowed
180
+ if destination_type not in ["SQS" , "SNS" , "S3" ]:
181
+ raise InvalidEventException (
182
+ self .logical_id , "The only valid values for 'Type' are 'SQS', 'SNS', and 'S3'"
183
+ )
182
184
if destination_type == "SQS" :
183
185
queue_arn = on_failure .get ("Destination" )
184
186
destination_config_policy = IAMRolePolicies ().sqs_send_message_role_policy (
@@ -189,6 +191,11 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P
189
191
destination_config_policy = IAMRolePolicies ().sns_publish_role_policy (
190
192
sns_topic_arn , self .logical_id
191
193
)
194
+ elif destination_type == "S3" :
195
+ s3_arn = on_failure .get ("Destination" )
196
+ destination_config_policy = IAMRolePolicies ().s3_send_event_payload_role_policy (
197
+ s3_arn , self .logical_id
198
+ )
192
199
193
200
lambda_eventsourcemapping .DestinationConfig = self .DestinationConfig
194
201
0 commit comments