1010class PullEventSource (ResourceMacro ):
1111 """Base class for pull event sources for SAM Functions.
1212
13- The pull events are Kinesis Streams, DynamoDB Streams, Kafka Topics, ActiveMQ Queues and SQS Queues. All of these correspond to an
13+ The pull events are Kinesis Streams, DynamoDB Streams, Kafka Topics, Amazon MQ Queues and SQS Queues. All of these correspond to an
1414 EventSourceMapping in Lambda, and require that the execution role be given to Kinesis Streams, DynamoDB
1515 Streams, or SQS Queues, respectively.
1616
@@ -74,7 +74,7 @@ def to_cloudformation(self, **kwargs):
7474 if not self .Stream and not self .Queue and not self .Broker :
7575 raise InvalidEventException (
7676 self .relative_id ,
77- "No Queue (for SQS) or Stream (for Kinesis, DynamoDB or MSK) or Broker (for ActiveMQ ) provided." ,
77+ "No Queue (for SQS) or Stream (for Kinesis, DynamoDB or MSK) or Broker (for Amazon MQ ) provided." ,
7878 )
7979
8080 if self .Stream and not self .StartingPosition :
@@ -218,23 +218,38 @@ def get_policy_statements(self):
218218 if not self .SourceAccessConfigurations :
219219 raise InvalidEventException (
220220 self .relative_id ,
221- "No SourceAccessConfigurations for ActiveMQ provided." ,
221+ "No SourceAccessConfigurations for Amazon MQ event provided." ,
222222 )
223223 if not type (self .SourceAccessConfigurations ) is list :
224224 raise InvalidEventException (
225225 self .relative_id ,
226226 "Provided SourceAccessConfigurations cannot be parsed into a list." ,
227227 )
228- # MQ only supports SourceAccessConfigurations with list size of 1
229- if not (len (self .SourceAccessConfigurations ) == 1 ):
230- raise InvalidEventException (
231- self .relative_id ,
232- "SourceAccessConfigurations for ActiveMQ only supports single configuration entry." ,
233- )
234- if not self .SourceAccessConfigurations [0 ].get ("URI" ):
228+ basic_auth_uri = None
229+ for conf in self .SourceAccessConfigurations :
230+ event_type = conf .get ("Type" )
231+ if event_type not in ("BASIC_AUTH" , "VIRTUAL_HOST" ):
232+ raise InvalidEventException (
233+ self .relative_id ,
234+ "Invalid property specified in SourceAccessConfigurations for Amazon MQ event." ,
235+ )
236+ if event_type == "BASIC_AUTH" :
237+ if basic_auth_uri :
238+ raise InvalidEventException (
239+ self .relative_id ,
240+ "Multiple BASIC_AUTH properties specified in SourceAccessConfigurations for Amazon MQ event." ,
241+ )
242+ basic_auth_uri = conf .get ("URI" )
243+ if not basic_auth_uri :
244+ raise InvalidEventException (
245+ self .relative_id ,
246+ "No BASIC_AUTH URI property specified in SourceAccessConfigurations for Amazon MQ event." ,
247+ )
248+
249+ if not basic_auth_uri :
235250 raise InvalidEventException (
236251 self .relative_id ,
237- "No URI property specified in SourceAccessConfigurations for ActiveMQ ." ,
252+ "No BASIC_AUTH property specified in SourceAccessConfigurations for Amazon MQ event ." ,
238253 )
239254 document = {
240255 "PolicyName" : "SamAutoGeneratedAMQPolicy" ,
@@ -245,7 +260,7 @@ def get_policy_statements(self):
245260 "secretsmanager:GetSecretValue" ,
246261 ],
247262 "Effect" : "Allow" ,
248- "Resource" : self . SourceAccessConfigurations [ 0 ]. get ( "URI" ) ,
263+ "Resource" : basic_auth_uri ,
249264 },
250265 {
251266 "Action" : [
0 commit comments