@@ -27,6 +27,7 @@ type Config = {
2727 deadLetterMessageRetentionPeriodSeconds : number ;
2828 deadLetterQueueEnabled : boolean ;
2929 enabled : boolean ;
30+ queuePolicyEnabled : boolean ;
3031 fifo : boolean ;
3132 visibilityTimeout : number ;
3233 rawMessageDelivery : boolean ;
@@ -131,6 +132,7 @@ const addResource = (
131132 * kmsDataKeyReusePeriodSeconds: 600
132133 * deadLetterMessageRetentionPeriodSeconds: 1209600
133134 * deadLetterQueueEnabled: true
135+ * queuePolicyEnabled: true
134136 * visibilityTimeout: 120
135137 * rawMessageDelivery: true
136138 * enabled: false
@@ -200,6 +202,7 @@ export default class ServerlessSnsSqsLambda {
200202 maximum : 1209600
201203 } ,
202204 deadLetterQueueEnabled : { type : "boolean" } ,
205+ queuePolicyEnabled : { type : "boolean" } ,
203206 rawMessageDelivery : { type : "boolean" } ,
204207 enabled : { type : "boolean" } ,
205208 fifo : { type : "boolean" } ,
@@ -315,6 +318,7 @@ Usage
315318 kmsDataKeyReusePeriodSeconds: 600 # optional - AWS default is 300 seconds
316319 deadLetterMessageRetentionPeriodSeconds: 1209600 # optional - AWS default is 345600 secs (4 days)
317320 deadLetterQueueEnabled: true # optional - default is enabled
321+ queuePolicyEnabled: true # optional - default is enabled
318322 enabled: true # optional - AWS default is true
319323 fifo: false # optional - AWS default is false
320324 visibilityTimeout: 30 # optional - AWS default is 30 seconds
@@ -362,6 +366,10 @@ Usage
362366 config . deadLetterQueueEnabled !== undefined
363367 ? config . deadLetterQueueEnabled
364368 : true ,
369+ queuePolicyEnabled :
370+ config . queuePolicyEnabled !== undefined
371+ ? config . queuePolicyEnabled
372+ : true ,
365373 enabled : config . enabled ,
366374 fifo : config . fifo !== undefined ? config . fifo : false ,
367375 visibilityTimeout : config . visibilityTimeout ,
@@ -600,14 +608,18 @@ Usage
600608 */
601609 addLambdaSqsPermissions (
602610 template ,
603- { name, kmsMasterKeyId, deadLetterQueueEnabled }
611+ { name, kmsMasterKeyId, deadLetterQueueEnabled, queuePolicyEnabled }
604612 ) {
605613 if ( template . Resources . IamRoleLambdaExecution === undefined ) {
606614 // The user has set their own custom role ARN so the Serverless generated role is not generated
607615 // We can safely skip this step because the owner of the custom role ARN is responsible for setting
608616 // this the relevant policy to allow the lambda to access the queue.
609617 return ;
610618 }
619+ if ( ! queuePolicyEnabled ) {
620+ // The user wants to use their own IAM policy and does not want plugin to automatically append to the default one.
621+ return ;
622+ }
611623 const queues = [ { "Fn::GetAtt" : [ `${ name } Queue` , "Arn" ] } ] ;
612624 if ( deadLetterQueueEnabled ) {
613625 queues . push ( { "Fn::GetAtt" : [ `${ name } DeadLetterQueue` , "Arn" ] } ) ;
0 commit comments