jets 3.1.0 → 4.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.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/CHANGELOG.md +55 -0
  4. data/README.md +1 -5
  5. data/backers.md +0 -5
  6. data/jets.gemspec +4 -4
  7. data/lib/jets/application/defaults.rb +7 -2
  8. data/lib/jets/application.rb +6 -7
  9. data/lib/jets/aws_info.rb +2 -2
  10. data/lib/jets/aws_services.rb +8 -0
  11. data/lib/jets/booter.rb +64 -5
  12. data/lib/jets/builders/code_builder.rb +35 -21
  13. data/lib/jets/builders/gem_replacer.rb +2 -7
  14. data/lib/jets/builders/ruby_packager.rb +37 -4
  15. data/lib/jets/cfn/builders/api_deployment_builder.rb +1 -1
  16. data/lib/jets/cfn/builders/api_gateway_builder.rb +31 -27
  17. data/lib/jets/cfn/builders/api_resources_builder.rb +1 -1
  18. data/lib/jets/cfn/builders/authorizer_builder.rb +1 -1
  19. data/lib/jets/cfn/builders/base_child_builder.rb +20 -1
  20. data/lib/jets/cfn/builders/interface.rb +19 -0
  21. data/lib/jets/cfn/builders/page_builder.rb +80 -0
  22. data/lib/jets/cfn/builders/parent_builder.rb +22 -3
  23. data/lib/jets/cfn/builders/shared_builder.rb +1 -1
  24. data/lib/jets/cfn/built_template.rb +1 -1
  25. data/lib/jets/cfn/ship.rb +9 -2
  26. data/lib/jets/cfn/status.rb +1 -1
  27. data/lib/jets/cfn/upload.rb +2 -2
  28. data/lib/jets/cli.rb +12 -5
  29. data/lib/jets/commands/call/base_guesser.rb +1 -1
  30. data/lib/jets/commands/clean/log.rb +3 -3
  31. data/lib/jets/commands/configure.rb +1 -1
  32. data/lib/jets/commands/console.rb +7 -1
  33. data/lib/jets/commands/delete.rb +1 -1
  34. data/lib/jets/commands/deploy.rb +2 -2
  35. data/lib/jets/commands/main.rb +6 -3
  36. data/lib/jets/commands/stack_info.rb +1 -1
  37. data/lib/jets/commands/templates/skeleton/Gemfile.tt +1 -1
  38. data/lib/jets/commands/templates/skeleton/config/application.rb.tt +2 -1
  39. data/lib/jets/commands/url.rb +1 -1
  40. data/lib/jets/core.rb +14 -2
  41. data/lib/jets/core_ext/file.rb +9 -0
  42. data/lib/jets/dotenv.rb +2 -2
  43. data/lib/jets/erb.rb +1 -1
  44. data/lib/jets/inflections.rb +1 -1
  45. data/lib/jets/internal/app/controllers/jets/bare_controller.rb +1 -1
  46. data/lib/jets/internal/app/functions/jets/base_path.rb +93 -3
  47. data/lib/jets/internal/app/functions/jets/base_path_mapping.rb +79 -8
  48. data/lib/jets/internal/app/jobs/jets/preheat_job.rb +6 -2
  49. data/lib/jets/job/base.rb +2 -0
  50. data/lib/jets/job/helpers/sns_event_helper.rb +8 -0
  51. data/lib/jets/job/helpers/sqs_event_helper.rb +8 -0
  52. data/lib/jets/lambda/dsl.rb +7 -1
  53. data/lib/jets/{naming.rb → names.rb} +3 -3
  54. data/lib/jets/preheat.rb +9 -6
  55. data/lib/jets/resource/api_gateway/base_path/role.rb +1 -1
  56. data/lib/jets/resource/api_gateway/deployment.rb +2 -2
  57. data/lib/jets/resource/api_gateway/rest_api/logical_id/message.rb +13 -3
  58. data/lib/jets/resource/api_gateway/rest_api/logical_id.rb +1 -1
  59. data/lib/jets/resource/api_gateway/rest_api/routes/change/base.rb +11 -40
  60. data/lib/jets/resource/api_gateway/rest_api/routes/change/media_types.rb +1 -1
  61. data/lib/jets/resource/api_gateway/rest_api/routes/change/page.rb +2 -2
  62. data/lib/jets/resource/api_gateway/rest_api/routes/change.rb +1 -1
  63. data/lib/jets/resource/api_gateway/rest_api.rb +12 -2
  64. data/lib/jets/resource/child_stack/api_deployment.rb +1 -1
  65. data/lib/jets/resource/child_stack/api_resource/page.rb +1 -1
  66. data/lib/jets/resource/child_stack/api_resource.rb +1 -1
  67. data/lib/jets/resource/child_stack/app_class.rb +1 -1
  68. data/lib/jets/resource/child_stack/shared.rb +1 -1
  69. data/lib/jets/resource/iam/base_role_definition.rb +0 -5
  70. data/lib/jets/resource/iam/policy.rb +31 -0
  71. data/lib/jets/resource/lambda/function/environment.rb +6 -3
  72. data/lib/jets/resource/lambda/function.rb +3 -3
  73. data/lib/jets/router/route.rb +18 -2
  74. data/lib/jets/router/state.rb +47 -0
  75. data/lib/jets/router.rb +12 -0
  76. data/lib/jets/stack/main/dsl/lambda.rb +1 -0
  77. data/lib/jets/tmp_loader.rb +1 -1
  78. data/lib/jets/turbo/database_yaml.rb +1 -1
  79. data/lib/jets/util/yamler.rb +16 -0
  80. data/lib/jets/version.rb +1 -1
  81. data/lib/jets.rb +2 -0
  82. metadata +26 -20
  83. data/.python-version +0 -1
  84. data/.ruby-version +0 -1
@@ -18,7 +18,7 @@ module Jets::Cfn::Builders
18
18
 
19
19
  # template_path is an interface method for Interface module
20
20
  def template_path
21
- Jets::Naming.app_template_path(@app_class)
21
+ Jets::Names.app_template_path(@app_class)
22
22
  end
23
23
 
24
24
  def add_common_parameters
@@ -40,6 +40,7 @@ module Jets::Cfn::Builders
40
40
  end
41
41
 
42
42
  def add_functions
43
+ validate_function_names!
43
44
  add_class_iam_policy
44
45
  @app_class.tasks.each do |task|
45
46
  add_function(task)
@@ -65,5 +66,23 @@ module Jets::Cfn::Builders
65
66
  resource = Jets::Resource::Iam::FunctionRole.new(task)
66
67
  add_resource(resource)
67
68
  end
69
+
70
+ def validate_function_names!
71
+ invalids = @app_class.tasks.reject do |task|
72
+ task.meth.to_s =~ /^[a-zA-Z][a-zA-Z0-9_]/
73
+ end
74
+ return if invalids.empty?
75
+ list = invalids.map do |task|
76
+ " #{task.class_name}##{task.meth}" # IE: PostsController#index
77
+ end.join("\n")
78
+ puts "ERROR: Detected invalid AWS Lambda function names".color(:red)
79
+ puts <<~EOL
80
+ Lambda function names must start with a letter and can only contain letters, numbers, and underscores.
81
+ Invalid function names:
82
+
83
+ #{list}
84
+ EOL
85
+ exit 1
86
+ end
68
87
  end
69
88
  end
@@ -88,8 +88,27 @@ module Jets::Cfn::Builders
88
88
  end
89
89
  end
90
90
 
91
+ # Note: Jets::Resource::Iam classes are special treated. They are the only resources that result
92
+ # in creating 2 CloudFormation resources: Iam::Policy and Iam::Role.
93
+ # This allows the user to refer to the Lambda Function name in the IAM Policy itself.
94
+ # We need separate resources to avoid CloudFormation erroring with a circular dependency.
95
+ # Using separate IAM::Policy and IAM::Role resources allows us avoid the circular dependency error.
96
+ #
97
+ # Handling logic here also centralizes code for this special behavior.
98
+ # Also important to note, this does not change the user-facing interface.
99
+ # IE: Users still uses code like:
100
+ #
101
+ # iam_policy("s3", "sns")
102
+ #
103
+ # and be none-the-wiser about the special behavior.
91
104
  def add_resource(resource)
92
105
  add_template_resource(resource.logical_id, resource.type, resource.attributes)
106
+
107
+ if resource.class.to_s.include?("Jets::Resource::Iam")
108
+ role = resource # for clarity: resource is a Iam::*Role class
109
+ iam_policy = Jets::Resource::Iam::Policy.new(role)
110
+ add_template_resource(iam_policy.logical_id, iam_policy.type, iam_policy.attributes)
111
+ end
93
112
  end
94
113
 
95
114
  # The add_resource method can take an options Hash with both with either
@@ -0,0 +1,80 @@
1
+ module Jets::Cfn::Builders
2
+ class PageBuilder
3
+ extend Memoist
4
+ cattr_reader :pages
5
+
6
+ # Build page slices
7
+ def build
8
+ map = build_map
9
+ pages = []
10
+ map.each do |path, existing_page|
11
+ if existing_page
12
+ pages[existing_page] ||= []
13
+ pages[existing_page] << path
14
+ end
15
+ end
16
+
17
+ # Remove existing paths from map. Leave behind new paths
18
+ pages.each do |page|
19
+ page.each do |i|
20
+ map.delete(i)
21
+ end
22
+ end
23
+
24
+ # Fill up available space in each page so all existing pages are full
25
+ keys = map.keys
26
+ pages.each do |page|
27
+ break if keys.empty?
28
+ while page.size < page_limit
29
+ path = keys.shift
30
+ break if path.nil?
31
+ page << path
32
+ end
33
+ end
34
+
35
+ # Add remaining slices to new additional pages
36
+ pages += keys.each_slice(page_limit).to_a
37
+
38
+ @@pages = pages
39
+
40
+ pages
41
+ end
42
+
43
+ # Build map that has paths as keys and page number as value
44
+ # Example: {"a1"=>0, "a2"=>0, "b1"=>1, "b2"=>1, "c1"=>2, "c2"=>2}
45
+ def build_map
46
+ map = {}
47
+ new_paths.each do |path|
48
+ map[path] = find_page_index(path)
49
+ end
50
+ map
51
+ end
52
+
53
+ def find_page_index(new_path)
54
+ pages = old_pages || []
55
+ pages.each_with_index do |slice, i|
56
+ slice.find do |old_path|
57
+ return i if old_path == new_path
58
+ end
59
+ end
60
+ nil
61
+ end
62
+
63
+ def old_pages
64
+ state = Jets::Router::State.new
65
+ state.load("pages")
66
+ end
67
+ memoize :old_pages
68
+
69
+ def new_paths
70
+ Jets::Router.all_paths.reject { |p| p == '' }
71
+ end
72
+
73
+ # Relevant is CloudFormation Outputs limit is 200
74
+ # JETS_APIGW_PAGE_LIMIT is based on that
75
+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html
76
+ def page_limit
77
+ Integer(ENV['JETS_APIGW_PAGE_LIMIT'] || 200)
78
+ end
79
+ end
80
+ end
@@ -19,14 +19,33 @@ module Jets::Cfn::Builders
19
19
 
20
20
  # template_path is an interface method
21
21
  def template_path
22
- Jets::Naming.parent_template_path
22
+ Jets::Names.parent_template_path
23
23
  end
24
24
 
25
25
  def build_minimal_resources
26
26
  add_description("Jets: #{Jets.version} Code: #{Util::Source.version}")
27
27
 
28
28
  # Initial s3 bucket, used to store code zipfile and templates Jets generates
29
+ #
30
+ # AWS changed the default behavior of s3 buckets to block public access
31
+ # https://aws.amazon.com/blogs/aws/amazon-s3-block-public-access-another-layer-of-protection-for-your-accounts-and-buckets/
32
+ # https://github.com/aws-amplify/amplify-cli/issues/12503
33
+ #
34
+ # Jets uploads assets to s3 bucket with acl: "public-read" here
35
+ # https://github.com/boltops-tools/jets/blob/c5858ec2706a606665a92c3ada3f16ae4c753372/lib/jets/cfn/upload.rb#L97
36
+ #
37
+ # Use minimal s3 bucket policy to allow public read access to assets.
38
+ # Leave the other options as comments to help document the default behavior.
29
39
  resource = Jets::Resource::S3::Bucket.new(logical_id: "s3_bucket",
40
+ PublicAccessBlockConfiguration: {
41
+ BlockPublicAcls: false,
42
+ # BlockPublicPolicy: false,
43
+ # IgnorePublicAcls: false,
44
+ # RestrictPublicBuckets: false
45
+ },
46
+ OwnershipControls: {
47
+ Rules: [{ObjectOwnership: "ObjectWriter"}]
48
+ },
30
49
  bucket_encryption: {
31
50
  server_side_encryption_configuration: [
32
51
  server_side_encryption_by_default: {
@@ -71,7 +90,7 @@ module Jets::Cfn::Builders
71
90
  # #{Jets.build_root}/templates/demo-dev-2-app-comments_controller.yml
72
91
  # #{Jets.build_root}/templates/demo-dev-2-authorizers-main_authorizer.yml
73
92
  def for_each_path(type)
74
- expression = "#{Jets::Naming.template_path_prefix}-#{type}-*"
93
+ expression = "#{Jets::Names.template_path_prefix}-#{type}-*"
75
94
  Dir.glob(expression).each do |path|
76
95
  next unless File.file?(path)
77
96
  yield(path)
@@ -104,7 +123,7 @@ module Jets::Cfn::Builders
104
123
  end
105
124
 
106
125
  def add_api_resources
107
- expression = "#{Jets::Naming.template_path_prefix}-api-resources-*"
126
+ expression = "#{Jets::Names.template_path_prefix}-api-resources-*"
108
127
  # IE: path: #{Jets.build_root}/templates/demo-dev-2-api-resources-1.yml"
109
128
  Dir.glob(expression).sort.each do |path|
110
129
  next unless File.file?(path)
@@ -8,7 +8,7 @@ module Jets::Cfn::Builders
8
8
 
9
9
  # template_path is an interface method for Interface module
10
10
  def template_path
11
- Jets::Naming.shared_template_path(@app_class)
11
+ Jets::Names.shared_template_path(@app_class)
12
12
  end
13
13
  end
14
14
  end
@@ -7,7 +7,7 @@ module Jets::Cfn
7
7
  if @@cache[path]
8
8
  @@cache[path] # using cache
9
9
  else
10
- @@cache[path] = YAML.load_file(path) # setting and using cache
10
+ @@cache[path] = Jets::Util::Yamler.load_file(path) # setting and using cache
11
11
  end
12
12
  end
13
13
  end
data/lib/jets/cfn/ship.rb CHANGED
@@ -5,7 +5,7 @@ module Jets::Cfn
5
5
 
6
6
  def initialize(options)
7
7
  @options = options
8
- @parent_stack_name = Jets::Naming.parent_stack_name
8
+ @parent_stack_name = Jets::Names.parent_stack_name
9
9
  end
10
10
 
11
11
  def run
@@ -42,6 +42,7 @@ module Jets::Cfn
42
42
  exit 1
43
43
  end
44
44
 
45
+ save_apigw_state
45
46
  prewarm
46
47
  clean_deploy_logs
47
48
  show_api_endpoint
@@ -80,7 +81,7 @@ module Jets::Cfn
80
81
  end
81
82
 
82
83
  def template
83
- @template ||= TemplateSource.new(Jets::Naming.parent_template_path, @options)
84
+ @template ||= TemplateSource.new(Jets::Names.parent_template_path, @options)
84
85
  end
85
86
 
86
87
  # check for /(_COMPLETE|_FAILED)$/ status
@@ -88,6 +89,12 @@ module Jets::Cfn
88
89
  Jets::Cfn::Status.new(@options).wait
89
90
  end
90
91
 
92
+ def save_apigw_state
93
+ state = Jets::Router::State.new
94
+ state.save("pages", Jets::Cfn::Builders::PageBuilder.pages)
95
+ state.save("routes", Jets::Router.routes)
96
+ end
97
+
91
98
  def prewarm
92
99
  if ENV['SKIP_PREWARMING']
93
100
  puts "Skipping prewarming" # useful for testing
@@ -3,7 +3,7 @@ require 'cfn_status'
3
3
  module Jets::Cfn
4
4
  class Status < CfnStatus
5
5
  def initialize(options={})
6
- @stack_name = Jets::Naming.parent_stack_name
6
+ @stack_name = Jets::Names.parent_stack_name
7
7
  super(@stack_name, options)
8
8
  end
9
9
  end
@@ -21,7 +21,7 @@ module Jets::Cfn
21
21
 
22
22
  def upload_cfn_templates
23
23
  puts "Uploading CloudFormation templates to S3."
24
- expression = "#{Jets::Naming.template_path_prefix}-*"
24
+ expression = "#{Jets::Names.template_path_prefix}-*"
25
25
  Dir.glob(expression).each do |path|
26
26
  next unless File.file?(path)
27
27
 
@@ -93,7 +93,7 @@ module Jets::Cfn
93
93
  key = s3_key(full_path)
94
94
  obj = s3_resource.bucket(bucket_name).object(key)
95
95
  content_type = content_type_headers(full_path)
96
- puts "Uploading and setting content type for s3://#{bucket_name}/#{key} content_type #{content_type[:content_type].inspect}"
96
+ Jets.logger.debug "Uploading and setting content type for s3://#{bucket_name}/#{key} content_type #{content_type[:content_type].inspect}"
97
97
  obj.upload_file(full_path, { acl: "public-read", cache_control: cache_control }.merge(content_type))
98
98
  end
99
99
 
data/lib/jets/cli.rb CHANGED
@@ -63,7 +63,8 @@ class Jets::CLI
63
63
  # Pretty tricky, we need to use the raw @given_args as thor_args eventually calls Commands::Base#eager_load!
64
64
  # which uses Jets.env before we get a chance to override ENV['JETS_ENV']
65
65
  command, env = @given_args[0..1]
66
- return unless %w[deploy delete].include?(command)
66
+
67
+ return unless %w[deploy delete console c].include?(command)
67
68
  env = nil if env&.starts_with?('-')
68
69
  return unless env
69
70
  ENV['JETS_ENV'] = env ? env : 'development'
@@ -136,10 +137,16 @@ class Jets::CLI
136
137
  end
137
138
 
138
139
  return unless jets_project?
139
- rake_task_found = Jets::Commands::RakeCommand.namespaced_commands.include?(full_command)
140
- if rake_task_found
141
- return Jets::Commands::RakeCommand
142
- end
140
+
141
+ Jets::Commands::RakeCommand if rake_task_found
142
+ end
143
+
144
+ def rake_task_found
145
+ return false unless full_command # can be nil for subcommands and would break jets help without this check
146
+ bracket_regex = /\[.*/ # matches everything after the first [
147
+ command = full_command.sub(bracket_regex, '') # remove everything after the first [
148
+ namespaced_commands = Jets::Commands::RakeCommand.namespaced_commands.map {|x| x.sub(bracket_regex, '') }
149
+ namespaced_commands.include?(command)
143
150
  end
144
151
 
145
152
  def jets_project?
@@ -56,7 +56,7 @@ class Jets::Commands::Call
56
56
 
57
57
  @@parent_stack = nil
58
58
  def parent_stack
59
- @@parent_stack ||= cfn.describe_stacks(stack_name: Jets::Naming.parent_stack_name).stacks.first
59
+ @@parent_stack ||= cfn.describe_stacks(stack_name: Jets::Names.parent_stack_name).stacks.first
60
60
  end
61
61
  end
62
62
  end
@@ -4,7 +4,7 @@
4
4
  # /aws/lambda/demo-dev-2-jets-preheat_job-warm
5
5
  # /aws/lambda/demo-dev-2-jets-public_controller-show
6
6
  #
7
- # We're doing this because JETS_ENV_EXTRA environments can create additional matching
7
+ # We're doing this because Jets.extra environments can create additional matching
8
8
  # log groups and we don't want to overly-aggressively delete them.
9
9
  #
10
10
  # The `keep_prefixes(log_group_names)` method calcuates the log groups to keep.
@@ -49,7 +49,7 @@ class Jets::Commands::Clean
49
49
 
50
50
  private
51
51
  def prefix_guess
52
- Jets::Naming.parent_stack_name
52
+ Jets::Names.parent_stack_name
53
53
  end
54
54
 
55
55
  def log_groups
@@ -78,7 +78,7 @@ class Jets::Commands::Clean
78
78
 
79
79
  # Check for the prefixes to keep. The slightly tricky thing to watch for is
80
80
  # for the prefix matching addiitonal log groups that belong to other
81
- # JETS_ENV_EXTRA=xxx created environments.
81
+ # JETS_EXTRA=xxx created environments.
82
82
  #
83
83
  # We find and store the prefixes to keep so we don't over aggressively delete
84
84
  # log groups.
@@ -16,7 +16,7 @@ module Jets::Commands
16
16
 
17
17
  def load_yaml
18
18
  if File.exist?(path)
19
- YAML.load_file(path)
19
+ Jets::Util::Yamler.load_file(path)
20
20
  else
21
21
  {}
22
22
  end
@@ -1,5 +1,11 @@
1
1
  class Jets::Commands::Console
2
- def self.run
2
+ attr_reader :environment
3
+
4
+ def initialize(environment)
5
+ @environment = environment
6
+ end
7
+
8
+ def run
3
9
  puts Jets::Booter.message
4
10
 
5
11
  # Thanks: https://mutelight.org/bin-console
@@ -90,7 +90,7 @@ class Jets::Commands::Delete
90
90
  end
91
91
 
92
92
  def parent_stack_name
93
- Jets::Naming.parent_stack_name
93
+ Jets::Names.parent_stack_name
94
94
  end
95
95
 
96
96
  def are_you_sure?
@@ -81,7 +81,7 @@ module Jets::Commands
81
81
  memoize :status
82
82
 
83
83
  def stack_name
84
- Jets::Naming.parent_stack_name
84
+ Jets::Names.parent_stack_name
85
85
  end
86
86
 
87
87
  # Checks for a few things before deciding to delete the parent stack
@@ -117,7 +117,7 @@ module Jets::Commands
117
117
  def exit_unless_updateable!
118
118
  return if ENV['JETS_FORCE_UPDATEABLE'] # useful for debugging if stack stack updating
119
119
 
120
- stack_name = Jets::Naming.parent_stack_name
120
+ stack_name = Jets::Names.parent_stack_name
121
121
  exists = stack_exists?(stack_name)
122
122
  return unless exists # continue because stack could be updating
123
123
 
@@ -61,10 +61,13 @@ module Jets::Commands
61
61
  Jets::Router.validate_routes!
62
62
  end
63
63
 
64
- desc "console", "REPL console with Jets environment loaded"
64
+ desc "console [environment]", "REPL console with Jets environment loaded"
65
65
  long_desc Help.text(:console)
66
- def console
67
- Console.run
66
+ # Note the environment is here to trick the Thor parser to allowing an
67
+ # environment parameter. It is not actually set here. It is set earlier
68
+ # in cli.rb: set_jets_env_from_cli_arg!
69
+ def console(environment=nil)
70
+ Console.new(options).run
68
71
  end
69
72
 
70
73
  desc "runner", "Run Ruby code in the context of Jets app non-interactively"
@@ -25,6 +25,6 @@ module Jets::Commands::StackInfo
25
25
  end
26
26
 
27
27
  def parent_stack_name
28
- Jets::Naming.parent_stack_name
28
+ Jets::Names.parent_stack_name
29
29
  end
30
30
  end
@@ -18,7 +18,7 @@ gem "mysql2", "~> 0.5.3"
18
18
  <% unless options[:mode] == 'job' -%>
19
19
  gem "dynomite"
20
20
  <% end -%>
21
- gem "zeitwerk", "~> 2.5.0"
21
+ gem "zeitwerk", ">= 2.5.0"
22
22
 
23
23
  # development and test groups are not bundled as part of the deployment
24
24
  group :development, :test do
@@ -11,7 +11,7 @@ Jets.application.configure do
11
11
  # config.prewarm.public_ratio = 3 # default is 3
12
12
  <% end -%>
13
13
 
14
- # config.env_extra = 2 # can also set this with JETS_ENV_EXTRA
14
+ # config.extra = 2 # can also set this with JETS_EXTRA
15
15
  # config.autoload_paths = []
16
16
 
17
17
  # config.asset_base_url = 'https://cloudfront.domain.com/assets' # example
@@ -35,6 +35,7 @@ Jets.application.configure do
35
35
  # security_group_ids: %w[sg-1 sg-2],
36
36
  # subnet_ids: %w[subnet-1 subnet-2],
37
37
  # }
38
+ # config.function.ephemeral_storage = { size: 1536 }
38
39
  # The config.function settings to the CloudFormation Lambda Function properties.
39
40
  # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
40
41
  # Underscored format can be used for keys to make it look more ruby-ish.
@@ -7,7 +7,7 @@ module Jets::Commands
7
7
  end
8
8
 
9
9
  def display
10
- stack_name = Jets::Naming.parent_stack_name
10
+ stack_name = Jets::Names.parent_stack_name
11
11
  unless stack_exists?(stack_name)
12
12
  puts "Stack for #{Jets.config.project_name.color(:green)} project for environment #{Jets.env.color(:green)}. Couldn't find #{stack_name.color(:green)} stack."
13
13
  exit
data/lib/jets/core.rb CHANGED
@@ -32,7 +32,19 @@ module Jets::Core
32
32
  end
33
33
  memoize :env
34
34
 
35
- def build_root
35
+ @@extra_warning_shown = false
36
+ def extra
37
+ # Keep for backwards compatibility
38
+ unless ENV['JETS_ENV_EXTRA'].blank?
39
+ puts "DEPRECATION WARNING: JETS_ENV_EXTRA is deprecated. Use JETS_EXTRA instead.".color(:yellow) unless @@extra_warning_shown
40
+ @@extra_warning_shown = true
41
+ extra = ENV['JETS_ENV_EXTRA']
42
+ end
43
+ extra = ENV['JETS_EXTRA'] unless ENV['JETS_EXTRA'].blank?
44
+ extra
45
+ end
46
+
47
+ def build_root
36
48
  "/tmp/jets/#{config.project_name}".freeze
37
49
  end
38
50
  memoize :build_root
@@ -76,7 +88,7 @@ module Jets::Core
76
88
  end
77
89
 
78
90
  def project_namespace
79
- [config.project_name, config.short_env, config.env_extra].compact.join('-').gsub('_','-')
91
+ [config.project_name, config.short_env, config.extra].compact.join('-').gsub('_','-')
80
92
  end
81
93
 
82
94
  def rack?
@@ -0,0 +1,9 @@
1
+ class File
2
+ class << self
3
+ # Ruby 3.2 removed File.exists?
4
+ # aws_config/store.rb uses it
5
+ # https://github.com/a2ikm/aws_config/blob/ef9cdd0eda116577f7d358bc421afd8e2f1eb1d3/lib/aws_config/store.rb#L6
6
+ # Probably a bunch of other libraries still use File.exists? also
7
+ alias_method :exists?, :exist?
8
+ end
9
+ end
data/lib/jets/dotenv.rb CHANGED
@@ -36,8 +36,8 @@ class Jets::Dotenv
36
36
  (root.join(".env.#{Jets.env}.local") unless @remote),
37
37
  ]
38
38
  files << root.join(".env.#{Jets.env}.remote") if @remote
39
- if ENV["JETS_ENV_EXTRA"]
40
- files << root.join(".env.#{Jets.env}.#{ENV["JETS_ENV_EXTRA"]}")
39
+ if Jets.extra
40
+ files << root.join(".env.#{Jets.env}.#{Jets.extra}")
41
41
  end
42
42
  files.compact
43
43
  end
data/lib/jets/erb.rb CHANGED
@@ -12,7 +12,7 @@ class Jets::Erb
12
12
  set_template_variables(variables)
13
13
  template = IO.read(path)
14
14
  begin
15
- ERB.new(template, nil, "-").result(binding)
15
+ ERB.new(template, trim_mode: '-').result(binding)
16
16
  rescue Exception => e
17
17
  puts e
18
18
  puts e.backtrace if ENV['JETS_DEBUG']
@@ -25,7 +25,7 @@ module Jets
25
25
  # User defined custom inflections
26
26
  def custom
27
27
  path = "#{Jets.root}/config/inflections.yml"
28
- File.exist?(path) ? YAML.load_file(path) : {}
28
+ File.exist?(path) ? Jets::Util::Yamler.load_file(path) : {}
29
29
  end
30
30
  end
31
31
  end
@@ -10,7 +10,7 @@ private
10
10
  def process!
11
11
  status, headers, body = dispatch!
12
12
  # Use the adapter only to convert the Rack triplet to a API Gateway hash structure
13
- adapter = Jets::Controller::Rack::Adapter.new(event, context, meth)
13
+ adapter = Jets::Controller::Rack::Adapter.new(event, context)
14
14
  adapter.convert_to_api_gateway(status, headers, body)
15
15
  end
16
16
  end