aws-sdk-rails 4.2.0 → 5.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e58942a12378042b0c5bdfe304b6b90f79dbc2d69c6dcdd00f0750a1faac0e2d
4
- data.tar.gz: 0fbb662869d4f5bb6c4fe1c9481fcdb842b6cfe8f7099568e9770364bed046d1
3
+ metadata.gz: b7354b35727ee37128ccb8b13f94a4d0564518e02e1acaf87086a3664fbea719
4
+ data.tar.gz: 8c9aae1eb8fed5ee9c4dca9d74fadd95619a0d05c455c9164dca9310002199db
5
5
  SHA512:
6
- metadata.gz: 187ff26d189951811d49dad748c7722baf91cf1160e62cdfbb219ebb7684cd61b814cc024d85cd7694f0dffac48c85fd5e4ac1c87ce811b2d4bb1aa2dfb102b4
7
- data.tar.gz: 9c3c281bc54ee18b98bde43c0f2832c08a131715af13e0f747544e2d78791e1579a00bb23486d72c74c7ad44784604fd9cf63befc9788c3cfe60c5637cb75e97
6
+ metadata.gz: e3c645120b3787a041900edd7365dec40d766807bc6c11fe81cd6788909d3f180c549fbd0e9071acfeefcd8608cc2e7d3d99f8f53d4ebf611742a33683eeddf0
7
+ data.tar.gz: 49743ff5d71ed4dfe915e6aa80cb6d1f1fdb6ba18d783330faae0e320435af92bb32ed78a042b3cb3be486e4a5cdf3826c723d36272a89a599c7f00c85ec0eca
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ 5.0.0 (2024-11-21)
2
+ ------------------
3
+
4
+ * Feature - [Major Version] Remove dependencies on modular feature gems: `aws-actiondispatch-dynamodb`, `aws-actionmailer-ses`, `aws-actionmailbox-ses`, `aws-activejob-sqs`, and `aws-record-rails`.
5
+
6
+ * Issue - Remove `Aws::Rails.add_action_mailer_delivery_method` in favor of `ActionMailer::Base.add_delivery_method` or the Railtie and configuration in `aws-actionmailer-ses ~> 1`.
7
+
8
+ * Issue - Remove require of `aws/rails/action_mailbox/rspec` in favor of `aws/action_mailbox/ses/rspec`.
9
+
10
+ * Issue - Remove symlinked namespaces from previous major versions.
11
+
12
+ * Feature - `ActiveSupport::Notifications` are enabled by default and removes `Aws::Rails.instrument_sdk_operations`.
13
+
14
+ * Feature - Moved railtie initializations to their appropriate spots.
15
+
16
+ * Issue - Do not execute `ActiveJob` from EB cron without the root path.
17
+
1
18
  4.2.0 (2024-11-20)
2
19
  ------------------
3
20
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.2.0
1
+ 5.0.0
@@ -31,37 +31,42 @@ module Aws
31
31
  private
32
32
 
33
33
  def execute_job(request)
34
- # Jobs queued from the Active Job SQS adapter contain the JSON message in the request body.
35
- job = Aws::Json.load(request.body.string)
34
+ # Jobs queued from the SQS adapter contain the JSON message in the request body.
35
+ job = ::ActiveSupport::JSON.decode(request.body.string)
36
36
  job_name = job['job_class']
37
37
  @logger.debug("Executing job: #{job_name}")
38
-
39
- begin
40
- ::ActiveJob::Base.execute(job)
41
- rescue NameError => e
42
- @logger.error("Job #{job_name} could not resolve to a class that inherits from Active Job.")
43
- @logger.error("Error: #{e}")
44
- return internal_error_response
45
- end
46
-
38
+ _execute_job(job, job_name)
47
39
  [200, { 'Content-Type' => 'text/plain' }, ["Successfully ran job #{job_name}."]]
40
+ rescue NameError
41
+ internal_error_response
42
+ end
43
+
44
+ def _execute_job(job, job_name)
45
+ ::ActiveJob::Base.execute(job)
46
+ rescue NameError => e
47
+ @logger.error("Job #{job_name} could not resolve to a class that inherits from Active Job.")
48
+ @logger.error("Error: #{e}")
49
+ raise e
48
50
  end
49
51
 
50
52
  def execute_periodic_task(request)
51
53
  # The beanstalk worker SQS Daemon will add the 'X-Aws-Sqsd-Taskname' for periodic tasks set in cron.yaml.
52
54
  job_name = request.headers['X-Aws-Sqsd-Taskname']
53
55
  @logger.debug("Creating and executing periodic task: #{job_name}")
54
-
55
- begin
56
- job = job_name.constantize.new
57
- job.perform_now
58
- rescue NameError => e
59
- @logger.error("Periodic task #{job_name} could not resolve to an Active Job class - check the spelling in cron.yaml.")
60
- @logger.error("Error: #{e}.")
61
- return internal_error_response
62
- end
63
-
56
+ _execute_periodic_task(job_name)
64
57
  [200, { 'Content-Type' => 'text/plain' }, ["Successfully ran periodic task #{job_name}."]]
58
+ rescue NameError
59
+ internal_error_response
60
+ end
61
+
62
+ def _execute_periodic_task(job_name)
63
+ job = job_name.constantize.new
64
+ job.perform_now
65
+ rescue NameError => e
66
+ @logger.error("Periodic task #{job_name} could not resolve to an Active Job class " \
67
+ '- check the cron name spelling and set the path as / in cron.yaml.')
68
+ @logger.error("Error: #{e}.")
69
+ raise e
65
70
  end
66
71
 
67
72
  def internal_error_response
@@ -84,7 +89,7 @@ module Aws
84
89
  # The beanstalk worker SQS Daemon will add the custom 'X-Aws-Sqsd-Taskname' header
85
90
  # for periodic tasks set in cron.yaml.
86
91
  def periodic_task?(request)
87
- !request.headers['X-Aws-Sqsd-Taskname'].nil? && request.headers['X-Aws-Sqsd-Taskname'].present?
92
+ request.headers['X-Aws-Sqsd-Taskname'].present? && request.fullpath == '/'
88
93
  end
89
94
 
90
95
  def sent_from_docker_host?(request)
@@ -112,6 +117,7 @@ module Aws
112
117
  @default_docker_ips ||= build_default_docker_ips
113
118
  end
114
119
 
120
+ # rubocop:disable Metrics/AbcSize
115
121
  def build_default_docker_ips
116
122
  default_gw_ips = ['172.17.0.1']
117
123
 
@@ -128,6 +134,7 @@ module Aws
128
134
 
129
135
  default_gw_ips
130
136
  end
137
+ # rubocop:enable Metrics/AbcSize
131
138
  end
132
139
  end
133
140
  end
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aws-sdk-core'
4
3
  require 'active_support/notifications'
5
4
 
5
+ require 'aws-sdk-core'
6
+
6
7
  module Aws
7
8
  module Rails
8
9
  # @api private
@@ -3,34 +3,24 @@
3
3
  module Aws
4
4
  # Use the Rails namespace.
5
5
  module Rails
6
+ # See https://guides.rubyonrails.org/configuring.html#initializers
6
7
  # @api private
7
8
  class Railtie < ::Rails::Railtie
8
- initializer 'aws-sdk-rails.initialize',
9
- before: :load_config_initializers do
10
- # Initialization Actions
11
- Aws::Rails.log_to_rails_logger
12
- Aws::Rails.use_rails_encrypted_credentials
13
- Aws::Rails.add_action_mailer_delivery_method
14
- Aws::Rails.add_action_mailer_delivery_method(:sesv2)
15
-
16
- if %i[ses sesv2].include?(::Rails.application.config.action_mailer.delivery_method)
17
- ::Rails.logger.warn(<<~MSG)
18
- ** Aws::Rails.add_action_mailer_delivery_method will be removed in aws-sdk-rails ~> 5.
19
- In `aws-actionmailer-ses ~> 1`, configuration will be set using config settings:
20
-
21
- config.action_mailer.delivery_method = :ses_v2
22
- config.action_mailer.ses_v2_settings = { region: 'us-west-2' }
23
-
24
- Existing Mailer classes have moved namespaces but will continue to work in this major version. **
25
- MSG
26
- end
9
+ # Set the logger for the AWS SDK to Rails.logger.
10
+ initializer 'aws-sdk-rails.log-to-rails-logger', after: :initialize_logger do
11
+ Aws.config[:logger] = ::Rails.logger
27
12
  end
28
13
 
29
- initializer 'aws-sdk-rails.insert_middleware' do |app|
30
- Aws::Rails.add_sqsd_middleware(app)
14
+ # Configures the AWS SDK with credentials from Rails encrypted credentials.
15
+ initializer 'aws-sdk-rails.use-rails-encrypted-credentials', after: :load_environment_config do
16
+ # limit the config keys we merge to credentials only
17
+ aws_credential_keys = %i[access_key_id secret_access_key session_token account_id]
18
+ creds = ::Rails.application.credentials[:aws].to_h.slice(*aws_credential_keys)
19
+ Aws.config.merge!(creds)
31
20
  end
32
21
 
33
- initializer 'aws-sdk-rails.eager_load' do
22
+ # Eager load the AWS SDK Clients.
23
+ initializer 'aws-sdk-rails.eager-load-sdk', before: :eager_load! do
34
24
  Aws.define_singleton_method(:eager_load!) do
35
25
  Aws.constants.each do |c|
36
26
  m = Aws.const_get(c)
@@ -46,65 +36,37 @@ module Aws
46
36
  config.eager_load_namespaces << Aws
47
37
  end
48
38
  end
49
- end
50
-
51
- # Configures the AWS SDK for Ruby's logger to use the Rails logger.
52
- def self.log_to_rails_logger
53
- Aws.config[:logger] = ::Rails.logger
54
- nil
55
- end
56
39
 
57
- # Configures the AWS SDK with credentials from Rails encrypted credentials.
58
- def self.use_rails_encrypted_credentials
59
- # limit the config keys we merge to credentials only
60
- aws_credential_keys = %i[access_key_id secret_access_key session_token account_id]
61
- creds = ::Rails.application.credentials[:aws].to_h.slice(*aws_credential_keys)
62
- Aws.config.merge!(creds)
63
- end
64
-
65
- # This is called automatically from the SDK's Railtie, but can be manually
66
- # called if you want to specify options for building the Aws::SES::Client or
67
- # Aws::SESV2::Client.
68
- #
69
- # @param [Symbol] name The name of the ActionMailer delivery method to
70
- # register, either :ses or :sesv2.
71
- # @param [Hash] client_options The options you wish to pass on to the
72
- # Aws::SES[V2]::Client initialization method.
73
- def self.add_action_mailer_delivery_method(name = :ses, client_options = {})
74
- # TODO: remove this method in aws-sdk-rails ~> 5
75
- ActiveSupport.on_load(:action_mailer) do
76
- if name == :sesv2
77
- add_delivery_method(name, Aws::Rails::Sesv2Mailer, client_options)
78
- else
79
- add_delivery_method(name, Aws::Rails::SesMailer, client_options)
40
+ # Add ActiveSupport Notifications instrumentation to AWS SDK client operations.
41
+ # Each operation will produce an event with a name `<operation>.<service>.aws`.
42
+ # For example, S3's put_object has an event name of: put_object.S3.aws
43
+ initializer 'aws-sdk-rails.instrument-sdk-operations', after: :load_active_support do
44
+ Aws.constants.each do |c|
45
+ m = Aws.const_get(c)
46
+ if m.is_a?(Module) && m.const_defined?(:Client) &&
47
+ (client = m.const_get(:Client)) && client.superclass == Seahorse::Client::Base
48
+ m.const_get(:Client).add_plugin(Aws::Rails::Notifications)
49
+ end
80
50
  end
81
51
  end
82
- end
83
52
 
84
- # Add ActiveSupport Notifications instrumentation to AWS SDK client operations.
85
- # Each operation will produce an event with a name `<operation>.<service>.aws`.
86
- # For example, S3's put_object has an event name of: put_object.S3.aws
87
- def self.instrument_sdk_operations
88
- Aws.constants.each do |c|
89
- m = Aws.const_get(c)
90
- if m.is_a?(Module) && m.const_defined?(:Client) &&
91
- (client = m.const_get(:Client)) && client.superclass == Seahorse::Client::Base
92
- m.const_get(:Client).add_plugin(Aws::Rails::Notifications)
93
- end
53
+ # Register a middleware that will handle requests from the Elastic Beanstalk worker SQS Daemon.
54
+ initializer 'aws-sdk-rails.add-sqsd-middleware', before: :build_middleware_stack do |app|
55
+ Aws::Rails.add_sqsd_middleware(app)
94
56
  end
95
57
  end
96
58
 
97
- # Register a middleware that will handle requests from the Elastic Beanstalk worker SQS Daemon.
98
- # This will only be added in the presence of the AWS_PROCESS_BEANSTALK_WORKER_REQUESTS environment variable.
99
- # The expectation is this variable should only be set on EB worker environments.
100
- def self.add_sqsd_middleware(app)
101
- return unless ENV['AWS_PROCESS_BEANSTALK_WORKER_REQUESTS']
59
+ class << self
60
+ # @api private
61
+ def add_sqsd_middleware(app)
62
+ return unless ENV['AWS_PROCESS_BEANSTALK_WORKER_REQUESTS']
102
63
 
103
- if app.config.force_ssl
104
- # SQS Daemon sends requests over HTTP - allow and process them before enforcing SSL.
105
- app.config.middleware.insert_before(::ActionDispatch::SSL, Aws::Rails::Middleware::ElasticBeanstalkSQSD)
106
- else
107
- app.config.middleware.use(Aws::Rails::Middleware::ElasticBeanstalkSQSD)
64
+ if app.config.force_ssl
65
+ # SQS Daemon sends requests over HTTP - allow and process them before enforcing SSL.
66
+ app.config.middleware.insert_before(::ActionDispatch::SSL, Aws::Rails::Middleware::ElasticBeanstalkSQSD)
67
+ else
68
+ app.config.middleware.use(Aws::Rails::Middleware::ElasticBeanstalkSQSD)
69
+ end
108
70
  end
109
71
  end
110
72
  end
data/lib/aws-sdk-rails.rb CHANGED
@@ -4,24 +4,8 @@ require_relative 'aws/rails/middleware/elastic_beanstalk_sqsd'
4
4
  require_relative 'aws/rails/railtie'
5
5
  require_relative 'aws/rails/notifications'
6
6
 
7
- # remove these in aws-sdk-rails 5
8
- require 'aws-actiondispatch-dynamodb'
9
- require 'aws-actionmailbox-ses' if defined?(ActionMailbox::Engine)
10
- require 'aws-actionmailer-ses'
11
- require 'aws-activejob-sqs'
12
- require 'aws-record-rails'
13
-
14
7
  module Aws
15
8
  module Rails
16
9
  VERSION = File.read(File.expand_path('../VERSION', __dir__)).strip
17
10
  end
18
11
  end
19
-
20
- # remove these in aws-sdk-rails 5
21
- Aws::Rails::SqsActiveJob = Aws::ActiveJob::SQS
22
- Aws::Rails::EbsSqsActiveJobMiddleware = Aws::Rails::Middleware::ElasticBeanstalkSQSD
23
- Aws::Rails::SesMailer = Aws::ActionMailer::SES::Mailer
24
- Aws::Rails::Sesv2Mailer = Aws::ActionMailer::SESV2::Mailer
25
- # This is for backwards compatibility after introducing support for SESv2.
26
- # The old mailer is now replaced with the new SES (v1) mailer.
27
- Aws::Rails::Mailer = Aws::Rails::SesMailer
metadata CHANGED
@@ -1,85 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 5.0.0
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-20 00:00:00.000000000 Z
11
+ date: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aws-actiondispatch-dynamodb
14
+ name: aws-sdk-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: aws-actionmailbox-ses
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: aws-actionmailer-ses
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: aws-activejob-sqs
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: aws-record-rails
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0'
26
+ version: '3'
83
27
  - !ruby/object:Gem::Dependency
84
28
  name: railties
85
29
  requirement: !ruby/object:Gem::Requirement
@@ -105,7 +49,6 @@ files:
105
49
  - LICENSE.txt
106
50
  - VERSION
107
51
  - lib/aws-sdk-rails.rb
108
- - lib/aws/rails/action_mailbox/rspec.rb
109
52
  - lib/aws/rails/middleware/elastic_beanstalk_sqsd.rb
110
53
  - lib/aws/rails/notifications.rb
111
54
  - lib/aws/rails/railtie.rb
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This can be deleted in aws-sdk-rails ~> 5
4
-
5
- require 'aws/action_mailbox/ses/rspec'
6
- Aws::Rails::ActionMailbox::RSpec = Aws::ActionMailbox::SES::RSpec
7
-
8
- Kernel.warn('Aws::Rails::ActionMailbox::RSpec is deprecated in aws-sdk-rails ~> 5. ' \
9
- 'Use Aws::ActionMailbox::SES::RSpec instead.')
10
- Kernel.warn('Please require "aws/action_mailbox/ses/rspec" instead of "aws/rails/action_mailbox/rspec"')