aws-sdk-rails 4.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +256 -0
  3. data/LICENSE.txt +12 -0
  4. data/VERSION +1 -1
  5. data/lib/aws/rails/middleware/elastic_beanstalk_sqsd.rb +141 -0
  6. data/lib/aws/rails/notifications.rb +5 -7
  7. data/lib/aws/rails/railtie.rb +38 -77
  8. data/lib/aws-sdk-rails.rb +1 -9
  9. metadata +14 -197
  10. data/app/controllers/action_mailbox/ingresses/ses/inbound_emails_controller.rb +0 -79
  11. data/bin/aws_sqs_active_job +0 -6
  12. data/config/routes.rb +0 -8
  13. data/lib/action_dispatch/session/dynamodb_store.rb +0 -38
  14. data/lib/active_job/queue_adapters/sqs_adapter/params.rb +0 -78
  15. data/lib/active_job/queue_adapters/sqs_adapter.rb +0 -58
  16. data/lib/active_job/queue_adapters/sqs_async_adapter.rb +0 -39
  17. data/lib/aws/rails/action_mailbox/engine.rb +0 -21
  18. data/lib/aws/rails/action_mailbox/rspec/email.rb +0 -50
  19. data/lib/aws/rails/action_mailbox/rspec/subscription_confirmation.rb +0 -37
  20. data/lib/aws/rails/action_mailbox/rspec.rb +0 -69
  21. data/lib/aws/rails/action_mailbox/s3_client.rb +0 -28
  22. data/lib/aws/rails/action_mailbox/sns_message_verifier.rb +0 -18
  23. data/lib/aws/rails/action_mailbox/sns_notification.rb +0 -99
  24. data/lib/aws/rails/middleware/ebs_sqs_active_job_middleware.rb +0 -118
  25. data/lib/aws/rails/ses_mailer.rb +0 -49
  26. data/lib/aws/rails/sesv2_mailer.rb +0 -60
  27. data/lib/aws/rails/sqs_active_job/configuration.rb +0 -184
  28. data/lib/aws/rails/sqs_active_job/deduplication.rb +0 -21
  29. data/lib/aws/rails/sqs_active_job/executor.rb +0 -77
  30. data/lib/aws/rails/sqs_active_job/job_runner.rb +0 -27
  31. data/lib/aws/rails/sqs_active_job/lambda_handler.rb +0 -63
  32. data/lib/aws/rails/sqs_active_job/poller.rb +0 -160
  33. data/lib/aws/rails/sqs_active_job.rb +0 -33
  34. data/lib/generators/aws_record/base.rb +0 -213
  35. data/lib/generators/aws_record/generated_attribute.rb +0 -138
  36. data/lib/generators/aws_record/model/USAGE +0 -24
  37. data/lib/generators/aws_record/model/model_generator.rb +0 -25
  38. data/lib/generators/aws_record/model/templates/model.erb +0 -48
  39. data/lib/generators/aws_record/model/templates/table_config.erb +0 -18
  40. data/lib/generators/aws_record/secondary_index.rb +0 -66
  41. data/lib/generators/dynamo_db/session_store_migration/USAGE +0 -13
  42. data/lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb +0 -48
  43. data/lib/generators/dynamo_db/session_store_migration/templates/dynamo_db_session_store.yml +0 -70
  44. data/lib/generators/dynamo_db/session_store_migration/templates/session_store_migration.erb +0 -9
  45. data/lib/tasks/aws_record/migrate.rake +0 -14
  46. data/lib/tasks/dynamo_db/session_store.rake +0 -10
@@ -1,138 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AwsRecord
4
- module Generators
5
- class GeneratedAttribute
6
- OPTS = %w[hkey rkey persist_nil db_attr_name ddb_type default_value].freeze
7
- INVALID_HKEY_TYPES = %i[map_attr list_attr numeric_set_attr string_set_attr].freeze
8
- attr_reader :name, :type
9
- attr_accessor :options
10
-
11
- def field_type
12
- case @type
13
- when :integer_attr then :number_field
14
- when :date_attr then :date_select
15
- when :datetime_attr then :datetime_select
16
- when :boolean_attr then :check_box
17
- else :text_field
18
- end
19
- end
20
-
21
- class << self
22
- def parse(field_definition)
23
- name, type, opts = field_definition.split(':')
24
- type ||= 'string'
25
- if OPTS.any? { |opt| type.include? opt }
26
- opts = type
27
- type = 'string'
28
- end
29
-
30
- opts = opts.split(',') if opts
31
- type, opts = parse_type_and_options(name, type, opts)
32
- validate_opt_combs(name, type, opts)
33
-
34
- new(name, type, opts)
35
- end
36
-
37
- private
38
-
39
- def validate_opt_combs(name, type, opts)
40
- return unless opts
41
-
42
- is_hkey = opts.key?(:hash_key)
43
- is_rkey = opts.key?(:range_key)
44
-
45
- if is_hkey && is_rkey
46
- raise ArgumentError,
47
- "Field #{name} cannot be a range key and hash key simultaneously"
48
- end
49
- return unless is_hkey && INVALID_HKEY_TYPES.include?(type)
50
-
51
- raise ArgumentError,
52
- "Field #{name} cannot be a hash key and be of type #{type}"
53
- end
54
-
55
- def parse_type_and_options(name, type, opts)
56
- opts ||= []
57
- [parse_type(name, type), opts.to_h { |opt| parse_option(name, opt) }]
58
- end
59
-
60
- def parse_option(name, opt)
61
- case opt
62
-
63
- when 'hkey'
64
- [:hash_key, true]
65
- when 'rkey'
66
- [:range_key, true]
67
- when 'persist_nil'
68
- [:persist_nil, true]
69
- when /db_attr_name\{(\w+)\}/
70
- [:database_attribute_name, "\"#{::Regexp.last_match(1)}\""]
71
- when /ddb_type\{(S|N|B|BOOL|SS|NS|BS|M|L)\}/i
72
- [:dynamodb_type, "\"#{::Regexp.last_match(1).upcase}\""]
73
- when /default_value\{(.+)\}/
74
- [:default_value, ::Regexp.last_match(1)]
75
- else
76
- raise ArgumentError, "You provided an invalid option for #{name}: #{opt}"
77
- end
78
- end
79
-
80
- def parse_type(name, type)
81
- case type.downcase
82
-
83
- when 'bool', 'boolean'
84
- :boolean_attr
85
- when 'date'
86
- :date_attr
87
- when 'datetime'
88
- :datetime_attr
89
- when 'float'
90
- :float_attr
91
- when 'int', 'integer'
92
- :integer_attr
93
- when 'list'
94
- :list_attr
95
- when 'map'
96
- :map_attr
97
- when 'num_set', 'numeric_set', 'nset'
98
- :numeric_set_attr
99
- when 'string_set', 's_set', 'sset'
100
- :string_set_attr
101
- when 'string'
102
- :string_attr
103
- else
104
- raise ArgumentError, "Invalid type for #{name}: #{type}"
105
- end
106
- end
107
- end
108
-
109
- def initialize(name, type = :string_attr, options = {})
110
- @name = name
111
- @type = type
112
- @options = options
113
- @digest = options.delete(:digest)
114
- end
115
-
116
- # Methods used by rails scaffolding
117
- def password_digest?
118
- @digest
119
- end
120
-
121
- def polymorphic?
122
- false
123
- end
124
-
125
- def column_name
126
- if @name == 'password_digest'
127
- 'password'
128
- else
129
- @name
130
- end
131
- end
132
-
133
- def human_name
134
- name.humanize
135
- end
136
- end
137
- end
138
- end
@@ -1,24 +0,0 @@
1
- Description:
2
- rails generator for aws-record models
3
-
4
- Pass the name of the model (preferably in singular form), and an optional list of attributes
5
-
6
- Attributes are declarations of the fields that you wish to store within a model. You can pass
7
- a type and list of options for each attribtue in the form: `name:type:options` if you do not provide
8
- a type, it is assumed that the attribute is of type `string_attr`
9
-
10
- Each model should have an hkey, if one is not present a `uuid:hkey` will be created for you.
11
-
12
- Timestamps are not added by default but you can add them using the `--timestamps` flag
13
- More information can be found at: https://github.com/awslabs/aws-record-generator/blob/master/README.md
14
-
15
- You don't have to think up every attribute up front, but it helps to
16
- sketch out a few so you can start working with the resource immediately.
17
-
18
- Example:
19
- rails generate aws_record:model Forum forum_uuid:hkey post_id:rkey post_title post_body tags:sset:default_value{Set.new} created_at:datetime:d_attr_name{PostCreatedAtTime} moderation:boolean:default_value{false}
20
-
21
- This will create:
22
- app/models/forum.rb
23
- db/table_config/forum_config.rb
24
- lib/tasks/table_config_migrate_task.rake # This is created once the first time the generator is run
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../base'
4
-
5
- module AwsRecord
6
- module Generators
7
- class ModelGenerator < Base
8
- def initialize(args, *options)
9
- self.class.source_root File.expand_path('templates', __dir__)
10
- super
11
- end
12
-
13
- def create_model
14
- template 'model.erb', File.join('app/models', class_path, "#{file_name}.rb")
15
- end
16
-
17
- def create_table_config
18
- return unless options['table_config']
19
-
20
- template 'table_config.erb',
21
- File.join('db/table_config', class_path, "#{file_name}_config.rb")
22
- end
23
- end
24
- end
25
- end
@@ -1,48 +0,0 @@
1
- require 'aws-record'
2
- <% if has_validations? -%>
3
- require 'active_model'
4
- <% end -%>
5
-
6
- <% module_namespacing do -%>
7
- class <%= class_name %>
8
- include Aws::Record
9
- <% if options.key? :scaffold -%>
10
- extend ActiveModel::Naming
11
- <% end -%>
12
- <% if has_validations? -%>
13
- include ActiveModel::Validations
14
- <% end -%>
15
- <% if options.key? :password_digest -%>
16
- include ActiveModel::SecurePassword
17
- <% end -%>
18
- <% if mutation_tracking_disabled? -%>
19
- disable_mutation_tracking
20
- <% end -%>
21
-
22
- <% attributes.each do |attribute| -%>
23
- <%= attribute.type %> :<%= attribute.name %><% *opts, last_opt = attribute.options.to_a %><%= ', ' if last_opt %><% opts.each do |opt| %><%= opt[0] %>: <%= opt[1] %>, <% end %><% if last_opt %><%= last_opt[0] %>: <%= last_opt[1] %><% end %>
24
- <% end -%>
25
- <% gsis.each do |index| %>
26
- global_secondary_index(
27
- :<%= index.name %>,
28
- hash_key: :<%= index.hash_key -%>,<%- if index.range_key %>
29
- range_key: :<%= index.range_key -%>,<%- end %>
30
- projection: {
31
- projection_type: <%= index.projection_type %>
32
- }
33
- )
34
- <% end -%>
35
- <% if !required_attrs.empty? -%>
36
- validates_presence_of <% *req, last_req = required_attrs -%><% req.each do |required_validation|-%>:<%= required_validation %>, <% end -%>:<%= last_req %>
37
- <% end -%>
38
- <% length_validations.each do |attribute, validation| -%>
39
- validates_length_of :<%= attribute %>, within: <%= validation %>
40
- <% end -%>
41
- <% if options['table_name'] -%>
42
- set_table_name "<%= options['table_name'] %>"
43
- <% end -%>
44
- <% if options.key? :password_digest -%>
45
- has_secure_password
46
- <% end -%>
47
- end
48
- <% end -%>
@@ -1,18 +0,0 @@
1
- require 'aws-record'
2
-
3
- module ModelTableConfig
4
- def self.config
5
- Aws::Record::TableConfig.define do |t|
6
- t.model_class <%= class_name %>
7
-
8
- t.read_capacity_units <%= primary_read_units %>
9
- t.write_capacity_units <%= primary_write_units %>
10
- <%- gsis.each do |index| %>
11
- t.global_secondary_index(:<%= index.name %>) do |i|
12
- i.read_capacity_units <%= gsi_rw_units[index.name][0] %>
13
- i.write_capacity_units <%= gsi_rw_units[index.name][1] %>
14
- end
15
- <%- end -%>
16
- end
17
- end
18
- end
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AwsRecord
4
- module Generators
5
- class SecondaryIndex
6
- PROJ_TYPES = %w[ALL KEYS_ONLY INCLUDE].freeze
7
- attr_reader :name, :hash_key, :range_key, :projection_type
8
-
9
- class << self
10
- def parse(key_definition)
11
- name, index_options = key_definition.split(':')
12
- index_options = index_options.split(',') if index_options
13
- opts = parse_raw_options(index_options)
14
-
15
- new(name, opts)
16
- end
17
-
18
- private
19
-
20
- def parse_raw_options(raw_opts)
21
- raw_opts ||= []
22
- raw_opts.to_h { |opt| get_option_value(opt) }
23
- end
24
-
25
- def get_option_value(raw_option)
26
- case raw_option
27
-
28
- when /hkey\{(\w+)\}/
29
- [:hash_key, ::Regexp.last_match(1)]
30
- when /rkey\{(\w+)\}/
31
- [:range_key, ::Regexp.last_match(1)]
32
- when /proj_type\{(\w+)\}/
33
- [:projection_type, ::Regexp.last_match(1)]
34
- else
35
- raise ArgumentError, "Invalid option for secondary index #{raw_option}"
36
- end
37
- end
38
- end
39
-
40
- def initialize(name, opts)
41
- raise ArgumentError, 'You must provide a name' unless name
42
- raise ArgumentError, 'You must provide a hash key' unless opts[:hash_key]
43
-
44
- if opts.key? :projection_type
45
- unless PROJ_TYPES.include? opts[:projection_type]
46
- raise ArgumentError, "Invalid projection type #{opts[:projection_type]}"
47
- end
48
- if opts[:projection_type] != 'ALL'
49
- raise NotImplementedError, 'ALL is the only projection type currently supported'
50
- end
51
- else
52
- opts[:projection_type] = 'ALL'
53
- end
54
-
55
- if opts[:hash_key] == opts[:range_key]
56
- raise ArgumentError, "#{opts[:hash_key]} cannot be both the rkey and hkey for gsi #{name}"
57
- end
58
-
59
- @name = name
60
- @hash_key = opts[:hash_key]
61
- @range_key = opts[:range_key]
62
- @projection_type = "\"#{opts[:projection_type]}\""
63
- end
64
- end
65
- end
66
- end
@@ -1,13 +0,0 @@
1
- Description:
2
- Generates a migration file for deleting and a creating a DynamoDB
3
- sessions table, and a configuration file for the session store.
4
-
5
- Example:
6
- rails generate dynamo_db:session_store_migration <MIGRATION_NAME>
7
-
8
- This will create:
9
- db/migrate/#{VERSION}_#{MIGRATION_NAME}.rb
10
- config/dynamo_db_session_store.yml
11
-
12
- The migration will be run when the command rake db:migrate is run
13
- in the command line.
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators/named_base'
4
-
5
- # This class generates a migration file for deleting and creating
6
- # a DynamoDB sessions table.
7
- module DynamoDb
8
- module Generators
9
- # Generates an ActiveRecord migration that creates and deletes a DynamoDB
10
- # Session table.
11
- class SessionStoreMigrationGenerator < Rails::Generators::NamedBase
12
- include Rails::Generators::Migration
13
-
14
- source_root File.expand_path('templates', __dir__)
15
-
16
- # Desired name of migration class
17
- argument :name, type: :string, default: 'create_dynamo_db_sessions_table'
18
-
19
- # @return [Rails Migration File] migration file for creation and deletion
20
- # of a DynamoDB session table.
21
- def generate_migration_file
22
- migration_template(
23
- 'session_store_migration.erb',
24
- "db/migrate/#{name.underscore}.rb"
25
- )
26
- end
27
-
28
- def copy_sample_config_file
29
- template(
30
- 'dynamo_db_session_store.yml',
31
- 'config/dynamo_db_session_store.yml'
32
- )
33
- end
34
-
35
- # Next migration number - must be implemented
36
- def self.next_migration_number(_dir = nil)
37
- Time.now.utc.strftime('%Y%m%d%H%M%S')
38
- end
39
-
40
- private
41
-
42
- # @return [String] activerecord migration version
43
- def migration_version
44
- "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}"
45
- end
46
- end
47
- end
48
- end
@@ -1,70 +0,0 @@
1
- # Uncomment and manipulate the key value pairs below
2
- # in order to configure the DynamoDB Session Store Application.
3
-
4
- # [String] The secret key for HMAC encryption. This defaults to
5
- # `Rails.application.secret_key_base`. You can use a different key if desired.
6
- #
7
- # secret_key: SECRET_KEY
8
-
9
- # [String] Session table name.
10
- #
11
- # table_name: Sessions
12
-
13
- # [String] Session table hash key name.
14
- #
15
- # table_key: session_id
16
-
17
- # [Boolean] Define as true or false depending on if you want a strongly
18
- # consistent read.
19
- # See AWS DynamoDB documentation for table consistent_read for more
20
- # information on this setting.
21
- #
22
- # consistent_read: true
23
-
24
- # [Integer] Maximum number of reads consumed per second before
25
- # DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation
26
- # or table read_capacity for more information on this setting.
27
- #
28
- # read_capacity: 10
29
-
30
- # [Integer] Maximum number of writes consumed per second before
31
- # DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation
32
- # or table write_capacity for more information on this setting.
33
- #
34
- # write_capacity: 5
35
-
36
- # [Boolean] Define as true or false depending on whether you want all errors to be
37
- # raised up the stack.
38
- #
39
- # raise_errors: false
40
-
41
- # [Integer] Maximum number of seconds earlier
42
- # from the current time that a session was created.
43
- # By default this is 7 days.
44
- #
45
- # max_age: 604800
46
-
47
- # [Integer] Maximum number of seconds
48
- # before the current time that the session was last accessed.
49
- # By default this is 5 hours.
50
- #
51
- # max_stale: 18000
52
-
53
- # [Boolean] Define as true or false for whether you want to enable locking
54
- # for all accesses to session data.
55
- #
56
- # enable_locking: false
57
-
58
- # [Integer] Time in milleseconds after which lock will expire.
59
- #
60
- # lock_expiry_time: 500
61
-
62
- # [Integer] Time in milleseconds to wait before retrying to obtain
63
- # lock once an attempt to obtain lock has been made and has failed.
64
- #
65
- # lock_retry_delay: 500
66
-
67
- # [Integer] Maximum time in seconds to wait to acquire lock
68
- # before giving up.
69
- #
70
- # lock_max_wait_time: 1
@@ -1,9 +0,0 @@
1
- class <%= name.camelize %> < ActiveRecord::Migration[<%= migration_version %>]
2
- def up
3
- Aws::SessionStore::DynamoDB::Table.create_table
4
- end
5
-
6
- def down
7
- Aws::SessionStore::DynamoDB::Table.delete_table
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- desc 'Run all table configs in table_config folder'
4
- namespace :aws_record do
5
- task migrate: :environment do
6
- Dir[File.join('db', 'table_config', '**/*.rb')].each do |filename|
7
- puts "running #{filename}"
8
- require(File.expand_path(filename))
9
-
10
- table_config = ModelTableConfig.config
11
- table_config.migrate! unless table_config.compatible?
12
- end
13
- end
14
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace 'dynamo_db' do
4
- namespace 'session_store' do
5
- desc 'Clean up old sessions in the Amazon DynamoDB session store table.'
6
- task clean: :environment do
7
- Aws::SessionStore::DynamoDB::GarbageCollection.collect_garbage
8
- end
9
- end
10
- end