aws-sdk-rails 3.13.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/app/controllers/action_mailbox/ingresses/ses/inbound_emails_controller.rb +79 -0
- data/config/routes.rb +8 -0
- data/lib/active_job/queue_adapters/{amazon_sqs_adapter → sqs_adapter}/params.rb +1 -1
- data/lib/active_job/queue_adapters/{amazon_sqs_adapter.rb → sqs_adapter.rb} +6 -5
- data/lib/active_job/queue_adapters/{amazon_sqs_async_adapter.rb → sqs_async_adapter.rb} +2 -2
- data/lib/aws/rails/action_mailbox/engine.rb +21 -0
- data/lib/aws/rails/action_mailbox/rspec/email.rb +50 -0
- data/lib/aws/rails/action_mailbox/rspec/subscription_confirmation.rb +37 -0
- data/lib/aws/rails/action_mailbox/rspec.rb +69 -0
- data/lib/aws/rails/action_mailbox/s3_client.rb +28 -0
- data/lib/aws/rails/action_mailbox/sns_message_verifier.rb +18 -0
- data/lib/aws/rails/action_mailbox/sns_notification.rb +99 -0
- data/lib/aws/rails/railtie.rb +10 -6
- data/lib/aws/rails/sqs_active_job/configuration.rb +4 -20
- data/lib/aws/rails/sqs_active_job/job_runner.rb +1 -0
- data/lib/aws/rails/sqs_active_job/lambda_handler.rb +4 -4
- data/lib/aws/rails/sqs_active_job.rb +33 -0
- data/lib/aws-sdk-rails.rb +2 -8
- data/lib/generators/aws_record/base.rb +2 -2
- data/lib/generators/aws_record/generated_attribute.rb +1 -1
- data/lib/generators/aws_record/secondary_index.rb +1 -1
- metadata +73 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b2a36be4e26aa7999922750428f26eb04b3b8c824ed1cc6179a98c3e6484f8d
|
4
|
+
data.tar.gz: 4de349a64752e7e61edf461c84d80a474035579aba144ef1eef13f16607e819c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a70a8509e17d875ca696518d52cfca863bdecbef8ee231884ad5508c9e0c018ce01e8867957a468438890d5e37176d78ac8a0213fc914644788cf4490e523ac
|
7
|
+
data.tar.gz: 8097f4409f61dc35f5ade004a26231daf0b957b6223c50cfed5c610287da8bff757eb9b73a8d09e916900d1870eee038367d267a23545ed0c05f88c84bd724c3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
4.0.2
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aws/rails/action_mailbox/sns_notification'
|
4
|
+
|
5
|
+
module ActionMailbox
|
6
|
+
module Ingresses
|
7
|
+
module Ses
|
8
|
+
# Ingests inbound emails from Amazon SES/SNS and confirms subscriptions.
|
9
|
+
#
|
10
|
+
# Subscription requests must provide the following parameters in a JSON body:
|
11
|
+
# - +Message+: Notification content
|
12
|
+
# - +MessagId+: Notification unique identifier
|
13
|
+
# - +Timestamp+: iso8601 timestamp
|
14
|
+
# - +TopicArn+: Topic identifier
|
15
|
+
# - +Type+: Type of event ("Subscription")
|
16
|
+
#
|
17
|
+
# Inbound email events must provide the following parameters in a JSON body:
|
18
|
+
# - +Message+: Notification content
|
19
|
+
# - +MessagId+: Notification unique identifier
|
20
|
+
# - +Timestamp+: iso8601 timestamp
|
21
|
+
# - +SubscribeURL+: Topic identifier
|
22
|
+
# - +TopicArn+: Topic identifier
|
23
|
+
# - +Type+: Type of event ("SubscriptionConfirmation")
|
24
|
+
#
|
25
|
+
# All requests are authenticated by validating the provided AWS signature.
|
26
|
+
#
|
27
|
+
# Returns:
|
28
|
+
#
|
29
|
+
# - <tt>204 No Content</tt> if a request is successfully processed
|
30
|
+
# - <tt>401 Unauthorized</tt> if a request does not contain a valid signature
|
31
|
+
# - <tt>404 Not Found</tt> if the Amazon ingress has not been configured
|
32
|
+
# - <tt>422 Unprocessable Entity</tt> if a request provides invalid parameters
|
33
|
+
class InboundEmailsController < ActionMailbox::BaseController
|
34
|
+
before_action :verify_authenticity, :validate_topic, :confirm_subscription
|
35
|
+
|
36
|
+
def create
|
37
|
+
head :bad_request unless notification.message_content.present?
|
38
|
+
|
39
|
+
ActionMailbox::InboundEmail.create_and_extract_message_id!(notification.message_content)
|
40
|
+
head :no_content
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def verify_authenticity
|
46
|
+
head :bad_request unless notification.present?
|
47
|
+
head :unauthorized unless notification.verified?
|
48
|
+
end
|
49
|
+
|
50
|
+
def confirm_subscription
|
51
|
+
return unless notification.type == 'SubscriptionConfirmation'
|
52
|
+
return head :ok if notification.subscription_confirmed?
|
53
|
+
|
54
|
+
Rails.logger.error('SNS subscription confirmation request rejected.')
|
55
|
+
head :unprocessable_entity
|
56
|
+
end
|
57
|
+
|
58
|
+
def validate_topic
|
59
|
+
return if valid_topic == notification.topic
|
60
|
+
|
61
|
+
Rails.logger.warn("Ignoring unknown topic: #{topic}")
|
62
|
+
head :unauthorized
|
63
|
+
end
|
64
|
+
|
65
|
+
def notification
|
66
|
+
@notification ||= Aws::Rails::ActionMailbox::SnsNotification.new(request.raw_post)
|
67
|
+
end
|
68
|
+
|
69
|
+
def topic
|
70
|
+
@topic ||= notification.topic
|
71
|
+
end
|
72
|
+
|
73
|
+
def valid_topic
|
74
|
+
::Rails.configuration.action_mailbox.ses.subscribed_topic
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/config/routes.rb
ADDED
@@ -4,7 +4,12 @@ require 'aws-sdk-sqs'
|
|
4
4
|
|
5
5
|
module ActiveJob
|
6
6
|
module QueueAdapters
|
7
|
-
|
7
|
+
# Set in rails config via config.active_job.queue_adapter = :sqs to use the SQS adapter
|
8
|
+
class SqsAdapter
|
9
|
+
def enqueue_after_transaction_commit?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
8
13
|
def enqueue(job)
|
9
14
|
_enqueue(job)
|
10
15
|
end
|
@@ -49,9 +54,5 @@ module ActiveJob
|
|
49
54
|
Aws::Rails::SqsActiveJob.config.client.send_message(send_message_opts)
|
50
55
|
end
|
51
56
|
end
|
52
|
-
|
53
|
-
# create an alias to allow `:amazon` to be used as the adapter name
|
54
|
-
# `:amazon` is the convention used for ActionMailer and ActiveStorage
|
55
|
-
AmazonAdapter = AmazonSqsAdapter
|
56
57
|
end
|
57
58
|
end
|
@@ -12,8 +12,8 @@ module ActiveJob
|
|
12
12
|
#
|
13
13
|
# To use this adapter, set up as:
|
14
14
|
#
|
15
|
-
# config.active_job.queue_adapter = :
|
16
|
-
class
|
15
|
+
# config.active_job.queue_adapter = :sqs_async
|
16
|
+
class SqsAsyncAdapter < SqsAdapter
|
17
17
|
private
|
18
18
|
|
19
19
|
def _enqueue(job, body = nil, send_message_opts = {})
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if defined?(ActionMailbox::Engine)
|
4
|
+
module Aws
|
5
|
+
module Rails
|
6
|
+
module ActionMailbox
|
7
|
+
# @api private
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
config.action_mailbox.ses = ActiveSupport::OrderedOptions.new
|
10
|
+
config.action_mailbox.ses.s3_client_options ||= {}
|
11
|
+
|
12
|
+
initializer 'aws-sdk-rails.mount_engine' do |app|
|
13
|
+
app.routes.append do
|
14
|
+
mount Engine => '/'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Rails
|
5
|
+
module ActionMailbox
|
6
|
+
module RSpec
|
7
|
+
# @api private
|
8
|
+
class Email
|
9
|
+
def initialize(authentic: true, topic: 'topic:arn:default', mail: default_mail, message_params: {})
|
10
|
+
@authentic = authentic
|
11
|
+
@topic = topic
|
12
|
+
@mail = mail
|
13
|
+
@message_params = message_params
|
14
|
+
end
|
15
|
+
|
16
|
+
def headers
|
17
|
+
{ 'content-type' => 'application/json' }
|
18
|
+
end
|
19
|
+
|
20
|
+
def url
|
21
|
+
'/rails/action_mailbox/ses/inbound_emails'
|
22
|
+
end
|
23
|
+
|
24
|
+
def params
|
25
|
+
{
|
26
|
+
'Type' => 'Notification',
|
27
|
+
'TopicArn' => @topic,
|
28
|
+
'Message' => message_json
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def message_json
|
33
|
+
{
|
34
|
+
'notificationType' => 'Received',
|
35
|
+
'content' => @mail.encoded
|
36
|
+
}.merge(@message_params).to_json
|
37
|
+
end
|
38
|
+
|
39
|
+
def authentic?
|
40
|
+
@authentic
|
41
|
+
end
|
42
|
+
|
43
|
+
def default_mail
|
44
|
+
Mail.new
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Rails
|
5
|
+
module ActionMailbox
|
6
|
+
module RSpec
|
7
|
+
# @api private
|
8
|
+
class SubscriptionConfirmation
|
9
|
+
def initialize(authentic: true, topic: 'topic:arn:default')
|
10
|
+
@authentic = authentic
|
11
|
+
@topic = topic
|
12
|
+
end
|
13
|
+
|
14
|
+
def url
|
15
|
+
'/rails/action_mailbox/ses/inbound_emails'
|
16
|
+
end
|
17
|
+
|
18
|
+
def headers
|
19
|
+
{ 'content-type' => 'application/json' }
|
20
|
+
end
|
21
|
+
|
22
|
+
def params
|
23
|
+
{
|
24
|
+
'Type' => 'SubscriptionConfirmation',
|
25
|
+
'TopicArn' => @topic,
|
26
|
+
'SubscribeURL' => 'http://example.com/subscribe'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def authentic?
|
31
|
+
@authentic
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aws/rails/action_mailbox/rspec/email'
|
4
|
+
require 'aws/rails/action_mailbox/rspec/subscription_confirmation'
|
5
|
+
require 'aws-sdk-sns'
|
6
|
+
require 'aws/rails/action_mailbox/sns_message_verifier'
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module Rails
|
10
|
+
module ActionMailbox
|
11
|
+
# Include the `Aws::Rails::ActionMailbox::RSpec` extension in your tests, like so:
|
12
|
+
# require 'aws/rails/action_mailbox/rspec'
|
13
|
+
# RSpec.configure do |config|
|
14
|
+
# config.include Aws::Rails::ActionMailbox::RSpec
|
15
|
+
# end
|
16
|
+
# Then, in a request spec, use like so:
|
17
|
+
# RSpec.describe 'amazon emails', type: :request do
|
18
|
+
# it 'delivers a subscription notification' do
|
19
|
+
# action_mailbox_ses_deliver_subscription_confirmation
|
20
|
+
# expect(response).to have_http_status :ok
|
21
|
+
# end
|
22
|
+
|
23
|
+
# it 'delivers an email notification' do
|
24
|
+
# action_mailbox_ses_deliver_email(mail: Mail.new(to: 'user@example.com'))
|
25
|
+
# expect(ActionMailbox::InboundEmail.last.mail.recipients).to eql ['user@example.com']
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
module RSpec
|
29
|
+
def action_mailbox_ses_deliver_subscription_confirmation(options = {})
|
30
|
+
subscription_confirmation = SubscriptionConfirmation.new(**options)
|
31
|
+
stub_aws_sns_message_verifier(subscription_confirmation)
|
32
|
+
stub_aws_sns_subscription_request
|
33
|
+
|
34
|
+
post subscription_confirmation.url,
|
35
|
+
params: subscription_confirmation.params,
|
36
|
+
headers: subscription_confirmation.headers,
|
37
|
+
as: :json
|
38
|
+
end
|
39
|
+
|
40
|
+
def action_mailbox_ses_deliver_email(options = {})
|
41
|
+
email = Email.new(**options)
|
42
|
+
stub_aws_sns_message_verifier(email)
|
43
|
+
|
44
|
+
post email.url,
|
45
|
+
params: email.params,
|
46
|
+
headers: email.headers,
|
47
|
+
as: :json
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def message_verifier(subscription_confirmation)
|
53
|
+
instance_double(Aws::SNS::MessageVerifier, authentic?: subscription_confirmation.authentic?)
|
54
|
+
end
|
55
|
+
|
56
|
+
def stub_aws_sns_message_verifier(notification)
|
57
|
+
allow(Aws::Rails::ActionMailbox::SnsMessageVerifier).to receive(:verifier) { message_verifier(notification) }
|
58
|
+
end
|
59
|
+
|
60
|
+
def stub_aws_sns_subscription_request
|
61
|
+
allow(Net::HTTP).to receive(:get_response).and_call_original
|
62
|
+
allow(Net::HTTP)
|
63
|
+
.to receive(:get_response)
|
64
|
+
.with(URI('http://example.com/subscribe')) { double(code: '200') }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aws-sdk-s3'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module Rails
|
7
|
+
module ActionMailbox
|
8
|
+
# @api private
|
9
|
+
class S3Client
|
10
|
+
class << self
|
11
|
+
def client
|
12
|
+
@client ||= build_client
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def build_client
|
18
|
+
client = Aws::S3::Client.new(
|
19
|
+
**::Rails.configuration.action_mailbox.ses.s3_client_options
|
20
|
+
)
|
21
|
+
client.config.user_agent_frameworks << 'aws-sdk-rails'
|
22
|
+
client
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aws-sdk-sns'
|
4
|
+
|
5
|
+
module Aws
|
6
|
+
module Rails
|
7
|
+
module ActionMailbox
|
8
|
+
# @api private
|
9
|
+
class SnsMessageVerifier
|
10
|
+
class << self
|
11
|
+
def verifier
|
12
|
+
@verifier ||= Aws::SNS::MessageVerifier.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aws-sdk-sns'
|
4
|
+
require 'aws/rails/action_mailbox/s3_client'
|
5
|
+
require 'aws/rails/action_mailbox/sns_message_verifier'
|
6
|
+
|
7
|
+
module Aws
|
8
|
+
module Rails
|
9
|
+
module ActionMailbox
|
10
|
+
# @api private
|
11
|
+
class SnsNotification
|
12
|
+
class MessageContentError < StandardError; end
|
13
|
+
|
14
|
+
def initialize(request_body)
|
15
|
+
@request_body = request_body
|
16
|
+
end
|
17
|
+
|
18
|
+
def subscription_confirmed?
|
19
|
+
(200..299).cover?(confirmation_response.code.to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
def verified?
|
23
|
+
SnsMessageVerifier.verifier.authentic?(@request_body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def topic
|
27
|
+
notification.fetch(:TopicArn)
|
28
|
+
end
|
29
|
+
|
30
|
+
def type
|
31
|
+
notification.fetch(:Type)
|
32
|
+
end
|
33
|
+
|
34
|
+
def message_content
|
35
|
+
raise MessageContentError, 'Incoming emails must have notificationType `Received`' unless receipt?
|
36
|
+
|
37
|
+
if content_in_s3?
|
38
|
+
s3_content
|
39
|
+
else
|
40
|
+
return message[:content] unless destination
|
41
|
+
|
42
|
+
"X-Original-To: #{destination}\n#{message[:content]}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def notification
|
49
|
+
@notification ||= JSON.parse(@request_body, symbolize_names: true)
|
50
|
+
rescue JSON::ParserError => e
|
51
|
+
Rails.logger.warn("Unable to parse SNS notification: #{e}")
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def s3_content
|
56
|
+
S3Client
|
57
|
+
.client
|
58
|
+
.get_object(key: key, bucket: bucket)
|
59
|
+
.body
|
60
|
+
.string
|
61
|
+
end
|
62
|
+
|
63
|
+
def message
|
64
|
+
@message ||= JSON.parse(notification[:Message], symbolize_names: true)
|
65
|
+
end
|
66
|
+
|
67
|
+
def destination
|
68
|
+
message.dig(:mail, :destination)&.first
|
69
|
+
end
|
70
|
+
|
71
|
+
def action
|
72
|
+
return unless message[:receipt]
|
73
|
+
|
74
|
+
message.fetch(:receipt).fetch(:action)
|
75
|
+
end
|
76
|
+
|
77
|
+
def bucket
|
78
|
+
action.fetch(:bucketName)
|
79
|
+
end
|
80
|
+
|
81
|
+
def key
|
82
|
+
action.fetch(:objectKey)
|
83
|
+
end
|
84
|
+
|
85
|
+
def content_in_s3?
|
86
|
+
action&.fetch(:type) == 'S3'
|
87
|
+
end
|
88
|
+
|
89
|
+
def receipt?
|
90
|
+
message.fetch(:notificationType) == 'Received'
|
91
|
+
end
|
92
|
+
|
93
|
+
def confirmation_response
|
94
|
+
@confirmation_response ||= Net::HTTP.get_response(URI(notification[:SubscribeURL]))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/aws/rails/railtie.rb
CHANGED
@@ -9,7 +9,7 @@ module Aws
|
|
9
9
|
before: :load_config_initializers do
|
10
10
|
# Initialization Actions
|
11
11
|
Aws::Rails.use_rails_encrypted_credentials
|
12
|
-
Aws::Rails.add_action_mailer_delivery_method
|
12
|
+
Aws::Rails.add_action_mailer_delivery_method(:ses)
|
13
13
|
Aws::Rails.add_action_mailer_delivery_method(:sesv2)
|
14
14
|
Aws::Rails.log_to_rails_logger
|
15
15
|
end
|
@@ -25,18 +25,22 @@ module Aws
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# This is called automatically from the SDK's Railtie, but can be manually
|
28
|
-
# called if you want to specify options for building the Aws::SES::Client
|
28
|
+
# called if you want to specify options for building the Aws::SES::Client or
|
29
|
+
# Aws::SESV2::Client.
|
29
30
|
#
|
30
31
|
# @param [Symbol] name The name of the ActionMailer delivery method to
|
31
|
-
# register.
|
32
|
+
# register, either :ses or :sesv2.
|
32
33
|
# @param [Hash] client_options The options you wish to pass on to the
|
33
34
|
# Aws::SES[V2]::Client initialization method.
|
34
|
-
def self.add_action_mailer_delivery_method(name
|
35
|
+
def self.add_action_mailer_delivery_method(name, client_options = {})
|
35
36
|
ActiveSupport.on_load(:action_mailer) do
|
36
|
-
|
37
|
+
case name
|
38
|
+
when :ses
|
39
|
+
add_delivery_method(name, Aws::Rails::SesMailer, client_options)
|
40
|
+
when :sesv2
|
37
41
|
add_delivery_method(name, Aws::Rails::Sesv2Mailer, client_options)
|
38
42
|
else
|
39
|
-
|
43
|
+
raise ArgumentError, "Unknown action mailer delivery method: #{name}"
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
@@ -2,22 +2,8 @@
|
|
2
2
|
|
3
3
|
module Aws
|
4
4
|
module Rails
|
5
|
+
# Configuration for AWS SQS ActiveJob.
|
5
6
|
module SqsActiveJob
|
6
|
-
# @return [Configuration] the (singleton) Configuration
|
7
|
-
def self.config
|
8
|
-
@config ||= Configuration.new
|
9
|
-
end
|
10
|
-
|
11
|
-
# @yield Configuration
|
12
|
-
def self.configure
|
13
|
-
yield(config)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.fifo?(queue_url)
|
17
|
-
queue_url.ends_with? '.fifo'
|
18
|
-
end
|
19
|
-
|
20
|
-
# Configuration for AWS SQS ActiveJob.
|
21
7
|
# Use +Aws::Rails::SqsActiveJob.config+ to access the singleton config instance.
|
22
8
|
class Configuration
|
23
9
|
# Default configuration options
|
@@ -90,7 +76,7 @@ module Aws
|
|
90
76
|
# @option options [Callable] :async_queue_error_handler An error handler
|
91
77
|
# to be called when the async active job adapter experiances an error
|
92
78
|
# queueing a job. Only applies when
|
93
|
-
# +active_job.queue_adapter = :
|
79
|
+
# +active_job.queue_adapter = :sqs_async+. Called with:
|
94
80
|
# [error, job, job_options]
|
95
81
|
#
|
96
82
|
# @option options [SQS::Client] :client SQS Client to use. A default
|
@@ -186,13 +172,11 @@ module Aws
|
|
186
172
|
|
187
173
|
# Avoid incompatible changes with Psych 4.0.0
|
188
174
|
# https://bugs.ruby-lang.org/issues/17866
|
189
|
-
# rubocop:disable Security/YAMLLoad
|
190
175
|
begin
|
191
|
-
YAML.
|
176
|
+
YAML.safe_load(source, aliases: true) || {}
|
192
177
|
rescue ArgumentError
|
193
|
-
YAML.
|
178
|
+
YAML.safe_load(source) || {}
|
194
179
|
end
|
195
|
-
# rubocop:enable Security/YAMLLoad
|
196
180
|
end
|
197
181
|
end
|
198
182
|
end
|
@@ -4,11 +4,11 @@ require 'aws-sdk-sqs'
|
|
4
4
|
|
5
5
|
module Aws
|
6
6
|
module Rails
|
7
|
+
# A lambda event handler to run jobs from an SQS queue trigger
|
8
|
+
# Trigger the lambda from your SQS queue
|
9
|
+
# Configure the entrypoint to: +config/environment.Aws::Rails::SqsActiveJob.lambda_job_handler+
|
10
|
+
# This will load your Rails environment, and then use this method as the handler.
|
7
11
|
module SqsActiveJob
|
8
|
-
# A lambda event handler to run jobs from an SQS queue trigger
|
9
|
-
# Trigger the lambda from your SQS queue
|
10
|
-
# Configure the entrypoint to: +config/environment.Aws::Rails::SqsActiveJob.lambda_job_handler+
|
11
|
-
# This will load your Rails environment, and then use this method as the handler.
|
12
12
|
def self.lambda_job_handler(event:, context:)
|
13
13
|
return 'no records to process' unless event['Records']
|
14
14
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../active_job/queue_adapters/sqs_adapter'
|
4
|
+
require_relative '../../active_job/queue_adapters/sqs_adapter/params'
|
5
|
+
require_relative '../../active_job/queue_adapters/sqs_async_adapter'
|
6
|
+
require_relative 'sqs_active_job/configuration'
|
7
|
+
require_relative 'sqs_active_job/deduplication'
|
8
|
+
require_relative 'sqs_active_job/executor'
|
9
|
+
require_relative 'sqs_active_job/job_runner'
|
10
|
+
require_relative 'sqs_active_job/lambda_handler'
|
11
|
+
|
12
|
+
module Aws
|
13
|
+
module Rails
|
14
|
+
# == AWS SQS ActiveJob.
|
15
|
+
#
|
16
|
+
# SQS-based queuing backend for Active Job.
|
17
|
+
module SqsActiveJob
|
18
|
+
# @return [Configuration] the (singleton) Configuration
|
19
|
+
def self.config
|
20
|
+
@config ||= Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# @yield Configuration
|
24
|
+
def self.configure
|
25
|
+
yield(config)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.fifo?(queue_url)
|
29
|
+
queue_url.ends_with? '.fifo'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/aws-sdk-rails.rb
CHANGED
@@ -3,18 +3,12 @@
|
|
3
3
|
require_relative 'aws/rails/ses_mailer'
|
4
4
|
require_relative 'aws/rails/sesv2_mailer'
|
5
5
|
require_relative 'aws/rails/railtie'
|
6
|
+
require_relative 'aws/rails/action_mailbox/engine'
|
6
7
|
require_relative 'aws/rails/notifications'
|
7
|
-
require_relative 'aws/rails/sqs_active_job
|
8
|
-
require_relative 'aws/rails/sqs_active_job/deduplication'
|
9
|
-
require_relative 'aws/rails/sqs_active_job/executor'
|
10
|
-
require_relative 'aws/rails/sqs_active_job/job_runner'
|
11
|
-
require_relative 'aws/rails/sqs_active_job/lambda_handler'
|
8
|
+
require_relative 'aws/rails/sqs_active_job'
|
12
9
|
require_relative 'aws/rails/middleware/ebs_sqs_active_job_middleware'
|
13
10
|
|
14
11
|
require_relative 'action_dispatch/session/dynamodb_store'
|
15
|
-
require_relative 'active_job/queue_adapters/amazon_sqs_adapter'
|
16
|
-
require_relative 'active_job/queue_adapters/amazon_sqs_adapter/params'
|
17
|
-
require_relative 'active_job/queue_adapters/amazon_sqs_async_adapter'
|
18
12
|
|
19
13
|
require_relative 'generators/aws_record/base'
|
20
14
|
|
@@ -141,9 +141,9 @@ module AwsRecord
|
|
141
141
|
|
142
142
|
@primary_read_units, @primary_write_units = parse_rw_units('primary')
|
143
143
|
|
144
|
-
@gsi_rw_units = @gsis.
|
144
|
+
@gsi_rw_units = @gsis.to_h do |idx|
|
145
145
|
[idx.name, parse_rw_units(idx.name)]
|
146
|
-
end
|
146
|
+
end
|
147
147
|
|
148
148
|
options['table_config'].each_key do |config|
|
149
149
|
next if config == 'primary'
|
@@ -54,7 +54,7 @@ module AwsRecord
|
|
54
54
|
|
55
55
|
def parse_type_and_options(name, type, opts)
|
56
56
|
opts ||= []
|
57
|
-
[parse_type(name, type), opts.
|
57
|
+
[parse_type(name, type), opts.to_h { |opt| parse_option(name, opt) }]
|
58
58
|
end
|
59
59
|
|
60
60
|
def parse_option(name, opt)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-sdk-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-record
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk-s3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.123.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.123.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: aws-sdk-ses
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,7 +85,7 @@ dependencies:
|
|
65
85
|
- !ruby/object:Gem::Version
|
66
86
|
version: 1.34.0
|
67
87
|
- !ruby/object:Gem::Dependency
|
68
|
-
name: aws-sdk-
|
88
|
+
name: aws-sdk-sns
|
69
89
|
requirement: !ruby/object:Gem::Requirement
|
70
90
|
requirements:
|
71
91
|
- - "~>"
|
@@ -73,7 +93,7 @@ dependencies:
|
|
73
93
|
version: '1'
|
74
94
|
- - ">="
|
75
95
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.
|
96
|
+
version: 1.61.0
|
77
97
|
type: :runtime
|
78
98
|
prerelease: false
|
79
99
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -83,63 +103,83 @@ dependencies:
|
|
83
103
|
version: '1'
|
84
104
|
- - ">="
|
85
105
|
- !ruby/object:Gem::Version
|
86
|
-
version: 1.
|
106
|
+
version: 1.61.0
|
87
107
|
- !ruby/object:Gem::Dependency
|
88
|
-
name: aws-
|
108
|
+
name: aws-sdk-sqs
|
89
109
|
requirement: !ruby/object:Gem::Requirement
|
90
110
|
requirements:
|
91
111
|
- - "~>"
|
92
112
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
113
|
+
version: '1'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.56.0
|
94
117
|
type: :runtime
|
95
118
|
prerelease: false
|
96
119
|
version_requirements: !ruby/object:Gem::Requirement
|
97
120
|
requirements:
|
98
121
|
- - "~>"
|
99
122
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
123
|
+
version: '1'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 1.56.0
|
101
127
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
128
|
+
name: actionmailbox
|
103
129
|
requirement: !ruby/object:Gem::Requirement
|
104
130
|
requirements:
|
105
131
|
- - ">="
|
106
132
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
133
|
+
version: 7.0.0
|
108
134
|
type: :runtime
|
109
135
|
prerelease: false
|
110
136
|
version_requirements: !ruby/object:Gem::Requirement
|
111
137
|
requirements:
|
112
138
|
- - ">="
|
113
139
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
140
|
+
version: 7.0.0
|
115
141
|
- !ruby/object:Gem::Dependency
|
116
|
-
name:
|
142
|
+
name: aws-sessionstore-dynamodb
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '2'
|
148
|
+
type: :runtime
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '2'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: concurrent-ruby
|
117
157
|
requirement: !ruby/object:Gem::Requirement
|
118
158
|
requirements:
|
119
159
|
- - ">="
|
120
160
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
161
|
+
version: 1.3.1
|
122
162
|
type: :runtime
|
123
163
|
prerelease: false
|
124
164
|
version_requirements: !ruby/object:Gem::Requirement
|
125
165
|
requirements:
|
126
166
|
- - ">="
|
127
167
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
168
|
+
version: 1.3.1
|
129
169
|
- !ruby/object:Gem::Dependency
|
130
|
-
name:
|
170
|
+
name: railties
|
131
171
|
requirement: !ruby/object:Gem::Requirement
|
132
172
|
requirements:
|
133
173
|
- - ">="
|
134
174
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
136
|
-
type: :
|
175
|
+
version: 7.0.0
|
176
|
+
type: :runtime
|
137
177
|
prerelease: false
|
138
178
|
version_requirements: !ruby/object:Gem::Requirement
|
139
179
|
requirements:
|
140
180
|
- - ">="
|
141
181
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
182
|
+
version: 7.0.0
|
143
183
|
description: Integrates the AWS Ruby SDK with Ruby on Rails
|
144
184
|
email:
|
145
185
|
- aws-dr-rubygems@amazon.com
|
@@ -149,17 +189,27 @@ extensions: []
|
|
149
189
|
extra_rdoc_files: []
|
150
190
|
files:
|
151
191
|
- VERSION
|
192
|
+
- app/controllers/action_mailbox/ingresses/ses/inbound_emails_controller.rb
|
152
193
|
- bin/aws_sqs_active_job
|
194
|
+
- config/routes.rb
|
153
195
|
- lib/action_dispatch/session/dynamodb_store.rb
|
154
|
-
- lib/active_job/queue_adapters/
|
155
|
-
- lib/active_job/queue_adapters/
|
156
|
-
- lib/active_job/queue_adapters/
|
196
|
+
- lib/active_job/queue_adapters/sqs_adapter.rb
|
197
|
+
- lib/active_job/queue_adapters/sqs_adapter/params.rb
|
198
|
+
- lib/active_job/queue_adapters/sqs_async_adapter.rb
|
157
199
|
- lib/aws-sdk-rails.rb
|
200
|
+
- lib/aws/rails/action_mailbox/engine.rb
|
201
|
+
- lib/aws/rails/action_mailbox/rspec.rb
|
202
|
+
- lib/aws/rails/action_mailbox/rspec/email.rb
|
203
|
+
- lib/aws/rails/action_mailbox/rspec/subscription_confirmation.rb
|
204
|
+
- lib/aws/rails/action_mailbox/s3_client.rb
|
205
|
+
- lib/aws/rails/action_mailbox/sns_message_verifier.rb
|
206
|
+
- lib/aws/rails/action_mailbox/sns_notification.rb
|
158
207
|
- lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb
|
159
208
|
- lib/aws/rails/notifications.rb
|
160
209
|
- lib/aws/rails/railtie.rb
|
161
210
|
- lib/aws/rails/ses_mailer.rb
|
162
211
|
- lib/aws/rails/sesv2_mailer.rb
|
212
|
+
- lib/aws/rails/sqs_active_job.rb
|
163
213
|
- lib/aws/rails/sqs_active_job/configuration.rb
|
164
214
|
- lib/aws/rails/sqs_active_job/deduplication.rb
|
165
215
|
- lib/aws/rails/sqs_active_job/executor.rb
|
@@ -191,14 +241,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
241
|
requirements:
|
192
242
|
- - ">="
|
193
243
|
- !ruby/object:Gem::Version
|
194
|
-
version: '2.
|
244
|
+
version: '2.7'
|
195
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
246
|
requirements:
|
197
247
|
- - ">="
|
198
248
|
- !ruby/object:Gem::Version
|
199
249
|
version: '0'
|
200
250
|
requirements: []
|
201
|
-
rubygems_version: 3.5.
|
251
|
+
rubygems_version: 3.5.11
|
202
252
|
signing_key:
|
203
253
|
specification_version: 4
|
204
254
|
summary: AWS SDK for Ruby on Rails Plugin
|