Class: Bauble::Resources::SQSQueue
- Defined in:
- lib/bauble/resources/sqs_queue.rb
Overview
SQS Queue
Instance Attribute Summary collapse
-
#dead_letter_queue ⇒ Object
Returns the value of attribute dead_letter_queue.
-
#encryption ⇒ Object
Returns the value of attribute encryption.
-
#encryption_master_key ⇒ Object
Returns the value of attribute encryption_master_key.
-
#lambda_targets ⇒ Object
Returns the value of attribute lambda_targets.
-
#message_retention ⇒ Object
Returns the value of attribute message_retention.
-
#name ⇒ Object
Returns the value of attribute name.
-
#visibility_timeout ⇒ Object
Returns the value of attribute visibility_timeout.
Attributes inherited from Resource
Instance Method Summary collapse
- #add_target(function) ⇒ Object
- #bundle ⇒ Object
-
#initialize(app, **kwargs) ⇒ SQSQueue
constructor
A new instance of SQSQueue.
- #synthesize ⇒ Object
Methods inherited from Resource
Constructor Details
#initialize(app, **kwargs) ⇒ SQSQueue
Returns a new instance of SQSQueue.
13 14 15 16 17 18 19 20 21 |
# File 'lib/bauble/resources/sqs_queue.rb', line 13 def initialize(app, **kwargs) super(app) @name = kwargs.fetch(:name) @visibility_timeout = kwargs.fetch(:visibility_timeout, 30) @message_retention = kwargs.fetch(:message_retention, 345_600) @dead_letter_queue = kwargs.fetch(:dead_letter_queue, nil) @content_based_deduplication = kwargs.fetch(:content_based_deduplication, false) @lambda_targets = [] end |
Instance Attribute Details
#dead_letter_queue ⇒ Object
Returns the value of attribute dead_letter_queue.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def dead_letter_queue @dead_letter_queue end |
#encryption ⇒ Object
Returns the value of attribute encryption.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def encryption @encryption end |
#encryption_master_key ⇒ Object
Returns the value of attribute encryption_master_key.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def encryption_master_key @encryption_master_key end |
#lambda_targets ⇒ Object
Returns the value of attribute lambda_targets.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def lambda_targets @lambda_targets end |
#message_retention ⇒ Object
Returns the value of attribute message_retention.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def @message_retention end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def name @name end |
#visibility_timeout ⇒ Object
Returns the value of attribute visibility_timeout.
10 11 12 |
# File 'lib/bauble/resources/sqs_queue.rb', line 10 def visibility_timeout @visibility_timeout end |
Instance Method Details
#add_target(function) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/bauble/resources/sqs_queue.rb', line 46 def add_target(function) @lambda_targets << { "#{@name}_to_#{function.name}" => { 'type' => 'aws:lambda:EventSourceMapping', 'properties' => { 'eventSourceArn' => "${#{name}.arn}", 'functionName' => "${#{function.name}.name}", 'batchSize' => 10 } } } function.role.add_policy_statement( effect: 'Allow', actions: ['sqs:ReceiveMessage', 'sqs:DeleteMessage', 'sqs:GetQueueAttributes'], resources: ["${#{name}.arn}"] ) end |
#bundle ⇒ Object
42 43 44 |
# File 'lib/bauble/resources/sqs_queue.rb', line 42 def bundle true end |
#synthesize ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bauble/resources/sqs_queue.rb', line 23 def synthesize base_template = { @name => { 'type' => 'aws:sqs:Queue', 'properties' => { 'name' => resource_name(@name), 'visibilityTimeoutSeconds' => @visibility_timeout, 'messageRetentionSeconds' => @message_retention }.compact } } base_template.merge!(dead_letter_queue_template) if @dead_letter_queue @lambda_targets.each { |target| base_template.merge!(target) } base_template end |