jets 4.0.3 → 4.0.5

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: 2656b9ad4b3542399efbba9eadb992532d2ebed430315280d3e1524a376b3674
4
- data.tar.gz: bcd37a34c13c7027b99854129cf537369dd357ba39edc7481416315d20137602
3
+ metadata.gz: 9573f84496ce6067ec6fd2ab846a9387c65755aea56eba1ab24ed35cf2a9cb04
4
+ data.tar.gz: bc403254b13de9d7db49a146d254b3269b9b02b748e504c98f88ebcd293c20be
5
5
  SHA512:
6
- metadata.gz: 4b16ac3cc3899c989c2de4670fbc6be7c2f9dc07b39869404ebbbc0689f458fc4befc699ccff3c14001946716288792077a006c97f9541f842040fa656e10a4b
7
- data.tar.gz: d6f6f26ea83268b6ca877cfe8f49660e15b0e6709cfb7e498bbdf9b87cccf81b4c7cd86f2e707dd4ba0adbed0a8e70ccf0bd06cef80b15fb60e5b689b739dcbf
6
+ metadata.gz: e81ee110ee967638949b27431392dda0717497d85ff5bb58613373088695be8b4aaaff706a9fbf7fedcf38fffe33d9bcb8842d1068cf9077637c3616d93fb822
7
+ data.tar.gz: fa499faf963ecdadbd9cfe0372dd9f02b1378550800a72496fac32b3e8438e05aa0763e9a473e7cfc02545fcaa5e945f7487735be754ee09eeb3950ed5f3d40d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [4.0.5] - 2023-10-19
7
+ - [#665](https://github.com/boltops-tools/jets/pull/665) only add add_stage_name when request is present
8
+ - [#669](https://github.com/boltops-tools/jets/pull/669) Add optional command args to the jets runner command.
9
+
10
+ ## [4.0.4] - 2023-09-07
11
+ - [#662](https://github.com/boltops-tools/jets/pull/662) fix vpc iam permissions
12
+
6
13
  ## [4.0.3] - 2023-08-03
7
14
  - [#657](https://github.com/boltops-tools/jets/pull/657) [Fix] ApiGateway for local Middleware: fix query_string_parameters
8
15
 
@@ -2,8 +2,8 @@ class Jets::Application
2
2
  module Defaults
3
3
  extend ActiveSupport::Concern
4
4
 
5
- included do
6
- def self.default_iam_policy
5
+ class_methods do
6
+ def default_iam_policy
7
7
  project_namespace = Jets.project_namespace
8
8
  logs = {
9
9
  action: ["logs:*"],
@@ -24,24 +24,23 @@ class Jets::Application
24
24
  }
25
25
  policies << cloudformation
26
26
 
27
- if Jets.config.function.vpc_config
28
- vpc = {
29
- action: %w[
30
- ec2:CreateNetworkInterface
31
- ec2:DeleteNetworkInterface
32
- ec2:DescribeNetworkInterfaces
33
- ec2:DescribeVpcs
34
- ec2:DescribeSubnets
35
- ec2:DescribeSecurityGroups
36
- ],
37
- effect: "Allow",
38
- resource: "*",
39
- }
40
- policies << vpc
41
- end
42
-
43
27
  policies
44
28
  end
29
+
30
+ def vpc_iam_policy_statement
31
+ {
32
+ Action: %w[
33
+ ec2:CreateNetworkInterface
34
+ ec2:DeleteNetworkInterface
35
+ ec2:DescribeNetworkInterfaces
36
+ ec2:DescribeVpcs
37
+ ec2:DescribeSubnets
38
+ ec2:DescribeSecurityGroups
39
+ ],
40
+ Effect: "Allow",
41
+ Resource: "*",
42
+ }
43
+ end
45
44
  end
46
45
 
47
46
  def default_config
@@ -201,5 +200,29 @@ class Jets::Application
201
200
  app/shared/functions
202
201
  ]
203
202
  end
203
+
204
+ # Used by app/jobs/jets/preheat_job.rb
205
+ def preheat_job_iam_policy
206
+ policy = [
207
+ {
208
+ Sid: "Statement1",
209
+ Action: ["logs:*"],
210
+ Effect: "Allow",
211
+ Resource: [{
212
+ "Fn::Sub": "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${JetsPreheatJobWarmLambdaFunction}"
213
+ }]
214
+ },
215
+ {
216
+ Sid: "Statement2",
217
+ Action: ["lambda:InvokeFunction", "lambda:InvokeAsync"],
218
+ Effect: "Allow",
219
+ Resource: [{
220
+ "Fn::Sub": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:#{Jets.project_namespace}-*"
221
+ }]
222
+ }
223
+ ]
224
+ policy << Jets::Application.vpc_iam_policy_statement if Jets.config.function.vpc_config
225
+ policy
226
+ end
204
227
  end
205
228
  end
@@ -14,4 +14,27 @@ puts "hello world: #{Jets.env}"
14
14
  ```
15
15
 
16
16
  $ jets runner file://script.rb
17
- hello world: development
17
+ hello world: development
18
+
19
+
20
+ Optionally pass in an argument on the command line:
21
+
22
+ Usage: jets runner file|Ruby code [args]
23
+
24
+ The argument will be assigned to the `args` variable.
25
+
26
+ Example:
27
+
28
+ $ jets runner 'puts "hello world with args: #{args}"' 123
29
+ hello world with args: 123
30
+
31
+
32
+ Example with script.rb:
33
+
34
+ ```ruby
35
+ puts "hello world with args: #{args}"
36
+ ```
37
+
38
+ $ jets runner file://script.rb 123
39
+ hello world with args: 123
40
+
@@ -72,8 +72,8 @@ module Jets::Commands
72
72
 
73
73
  desc "runner", "Run Ruby code in the context of Jets app non-interactively"
74
74
  long_desc Help.text(:runner)
75
- def runner(code)
76
- Runner.run(code)
75
+ def runner(code, args=nil)
76
+ Runner.run(code, args)
77
77
  end
78
78
 
79
79
  desc "dbconsole", "Starts DB REPL console"
@@ -1,5 +1,5 @@
1
1
  class Jets::Commands::Runner
2
- def self.run(code)
2
+ def self.run(code, args=nil)
3
3
  if code =~ %r{^file://}
4
4
  path = code.sub('file://', '')
5
5
  full_path = "#{Jets.root}/#{path}"
@@ -7,24 +7,7 @@ class Jets::PreheatJob < ApplicationJob
7
7
 
8
8
  class_timeout 30
9
9
  class_memory 1024
10
- class_iam_policy(
11
- {
12
- sid: "Statement1",
13
- action: ["logs:*"],
14
- effect: "Allow",
15
- resource: [
16
- sub("arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${WarmLambdaFunction}"),
17
- ]
18
- },
19
- {
20
- Sid: "Statement2",
21
- Action: ["lambda:InvokeFunction", "lambda:InvokeAsync"],
22
- Effect: "Allow",
23
- Resource: [
24
- sub("arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:#{Jets.project_namespace}-*")
25
- ]
26
- }
27
- )
10
+ class_iam_policy(Jets.config.preheat_job_iam_policy)
28
11
 
29
12
  rate(PREWARM_RATE) if torching
30
13
  def torch
@@ -2,7 +2,7 @@ module Jets::CommonMethods
2
2
  extend Memoist
3
3
  # Add API Gateway Stage Name
4
4
  def add_stage_name(url)
5
- Jets::Controller::Stage.add(request.host, url)
5
+ Jets::Controller::Stage.add(request.host, url) if request.present?
6
6
  end
7
7
 
8
8
  def on_aws?
@@ -24,6 +24,12 @@ module Jets::Resource::Iam
24
24
  }
25
25
  }
26
26
 
27
+ # Add vpc permissions to all policies
28
+ definition[logical_id][:properties][:policies] = [
29
+ policy_name: "vpc", # required, limited to 128-chars
30
+ policy_document: vpc_policy_document,
31
+ ] if vpc_policy_document
32
+
27
33
  unless managed_policy_arns.empty?
28
34
  definition[logical_id][:properties][:managed_policy_arns] = managed_policy_arns
29
35
  end
@@ -31,6 +37,14 @@ module Jets::Resource::Iam
31
37
  definition
32
38
  end
33
39
 
40
+ def vpc_policy_document
41
+ if Jets.config.function.vpc_config
42
+ {
43
+ Statement: [Jets::Application.vpc_iam_policy_statement]
44
+ }
45
+ end
46
+ end
47
+
34
48
  def policy_document
35
49
  PolicyDocument.new(@policy_definitions.flatten.uniq).policy_document
36
50
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "4.0.3"
2
+ VERSION = "4.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-03 00:00:00.000000000 Z
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -1101,7 +1101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1101
1101
  - !ruby/object:Gem::Version
1102
1102
  version: '0'
1103
1103
  requirements: []
1104
- rubygems_version: 3.4.17
1104
+ rubygems_version: 3.4.20
1105
1105
  signing_key:
1106
1106
  specification_version: 4
1107
1107
  summary: Ruby Serverless Framework