@@ -407,7 +407,7 @@ def to_cloudformation(self, **kwargs):
407
407
queue_arn = queue .get_runtime_attr ("arn" )
408
408
queue_url = queue .get_runtime_attr ("queue_url" )
409
409
410
- queue_policy = self ._inject_sqs_queue_policy (self .Topic , queue_arn , queue_url )
410
+ queue_policy = self ._inject_sqs_queue_policy (self .Topic , queue_arn , queue_url , function . resource_attributes )
411
411
subscription = self ._inject_subscription (
412
412
"sqs" , queue_arn , self .Topic , self .Region , self .FilterPolicy , function .resource_attributes
413
413
)
@@ -430,7 +430,9 @@ def to_cloudformation(self, **kwargs):
430
430
batch_size = self .SqsSubscription .get ("BatchSize" , None )
431
431
enabled = self .SqsSubscription .get ("Enabled" , None )
432
432
433
- queue_policy = self ._inject_sqs_queue_policy (self .Topic , queue_arn , queue_url , queue_policy_logical_id )
433
+ queue_policy = self ._inject_sqs_queue_policy (
434
+ self .Topic , queue_arn , queue_url , function .resource_attributes , queue_policy_logical_id
435
+ )
434
436
subscription = self ._inject_subscription (
435
437
"sqs" , queue_arn , self .Topic , self .Region , self .FilterPolicy , function .resource_attributes
436
438
)
@@ -466,8 +468,11 @@ def _inject_sqs_event_source_mapping(self, function, role, queue_arn, batch_size
466
468
event_source .Enabled = enabled or True
467
469
return event_source .to_cloudformation (function = function , role = role )
468
470
469
- def _inject_sqs_queue_policy (self , topic_arn , queue_arn , queue_url , logical_id = None ):
471
+ def _inject_sqs_queue_policy (self , topic_arn , queue_arn , queue_url , resource_attributes , logical_id = None ):
470
472
policy = SQSQueuePolicy (logical_id or self .logical_id + "QueuePolicy" )
473
+ if CONDITION in resource_attributes :
474
+ policy .set_resource_attribute (CONDITION , resource_attributes [CONDITION ])
475
+
471
476
policy .PolicyDocument = SQSQueuePolicies .sns_topic_send_message_role_policy (topic_arn , queue_arn )
472
477
policy .Queues = [queue_url ]
473
478
return policy
0 commit comments