jets 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb8be5eb8194cd0e2d6ac3f718e4ecdb2a4a14ef785b513e32bb097a9402e417
4
- data.tar.gz: e70d4f88f3e0b8701a16c2115cdc5ad8a463447ba45ffc6adcf32e494a431690
3
+ metadata.gz: 557604f70083b13e25eb88496bbc2709d715688386e6cea83fc6d84d9c830799
4
+ data.tar.gz: 618b800e673d812303e28411d8cc16304777141a195c2ddd3029f416ed755591
5
5
  SHA512:
6
- metadata.gz: eef24ef7e8533bab5e98b3ca06205f219ec46ad7e0a8ba84cdf9a687ee9122253b17942e661990b2fb82be4aa28501076eae9626b8aea4958b2347241ca7a75f
7
- data.tar.gz: 98f1272457a69bc6ae50f093f32c2f130c3ca32dbf0235fbf82bd449612f2001edc3faab2f0957c7df7dd7c823548806d4329a62f1e11d9fa1346ca48d66c267
6
+ metadata.gz: 25c15f2f3f7ecf2d5b40ade99d990d2548be2c03f4a4312616aecff04482ca6a193a100e0c4851572ee3692b91534811f431c51640aff718645e7447fa4950b9
7
+ data.tar.gz: 9e16e4ad95fd469021853e328e982c22eed8dff9e85feb7f77c1a216c407e7239715399255afa0770f813858129b45707e1563673a2dfe25046c009ac8bf8463
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
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/), even before v1.0.
5
5
 
6
+ ## [0.6.9]
7
+ - add aws managed rule support, pull request #18
8
+
6
9
  ## [0.6.8]
7
10
  - add jets clean:log and clean:build commands pull request #17
8
11
  - allow integration.sh test script to run locally
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- jets (0.6.8)
14
+ jets (0.6.9)
15
15
  actionpack (>= 5.2.1)
16
16
  actionview (>= 5.2.1)
17
17
  activerecord (>= 5.2.1)
@@ -64,7 +64,7 @@ GEM
64
64
  tzinfo (~> 1.1)
65
65
  arel (9.0.0)
66
66
  aws-eventstream (1.0.1)
67
- aws-partitions (1.100.0)
67
+ aws-partitions (1.102.0)
68
68
  aws-sdk-cloudformation (1.6.0)
69
69
  aws-sdk-core (~> 3)
70
70
  aws-sigv4 (~> 1.0)
data/bin/release ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ # Wrapper release script so we don't forget to add submodules.
4
+ # Should still update the CHANGELOG.md and version.rb before running this script.
5
+
6
+ git submodule init
7
+ git submodule update
8
+ bundle update
9
+ rake release
@@ -5,8 +5,9 @@
5
5
  class Jets::Cfn::TemplateBuilders
6
6
  module Interface
7
7
  def build
8
- return if @app_klass && @app_klass.tasks.empty? # do not bother building
9
- #or writing the template unless there are functions defined
8
+ # Do not bother building
9
+ # or writing the template unless there are functions defined
10
+ return if @app_klass && !@app_klass.build?
10
11
 
11
12
  compose # must be implemented by subclass
12
13
  write
@@ -7,6 +7,7 @@ class Jets::Cfn::TemplateBuilders
7
7
  end
8
8
 
9
9
  def add_config_rules
10
+ # Handle config_rules associated with lambda functions.
10
11
  # @app_klass is PostsController, HardRule, Hello, or HelloFunction, or GameRule
11
12
  @app_klass.tasks.each do |task|
12
13
  map = Jets::Cfn::TemplateMappers::ConfigRuleMapper.new(task)
@@ -14,8 +15,23 @@ class Jets::Cfn::TemplateBuilders
14
15
  add_config_rule(task, map)
15
16
  add_permission(map)
16
17
  end
18
+
19
+ # Handle config_rules associated with aws managed rules.
20
+ # List of AWS Config Managed Rules: https://amzn.to/2BOt9KN
21
+ @app_klass.managed_rules.each do |rule|
22
+ map = Jets::Cfn::TemplateMappers::ConfigRuleMapper.new(rule)
23
+ add_aws_managed_rule(rule, map)
24
+ end
17
25
  end
18
26
 
27
+ def add_aws_managed_rule(rule, map)
28
+ # Usually we build the properties with the mappers but in the case for
29
+ # a config_rule it makes more sense to grab properties from the task
30
+ # using config_rule_properties
31
+ add_resource(map.logical_id, "AWS::Config::ConfigRule",
32
+ Properties: rule.config_rule_properties
33
+ )
34
+ end
19
35
 
20
36
  def add_config_rule(task, map)
21
37
  # Usually we build the properties with the mappers but in the case for
@@ -64,7 +64,7 @@ class Jets::Commands::Base < Thor
64
64
  class_name.sub!(/Task$/, "Tasks") # special rule here for Tasks class
65
65
  # NOTE: Weird thing where Jets::Commands::Db::Task => Thor::Command
66
66
  # because Task is a class available to Thor I believe.
67
- puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['DEBUG']
67
+ puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['JETS_DEBUG']
68
68
  class_name.constantize # dont have to worry about order.
69
69
  end
70
70
  end
@@ -7,7 +7,7 @@ Jets.application.configure do
7
7
  # config.extra_autoload_paths = []
8
8
 
9
9
  config.function.timeout = 10
10
- # config.function.role = "arn:aws:iam::#{ENV['AWS_ACCOUNT_ID']}:role/service-role/pre-created"
10
+ # config.function.role = "arn:aws:iam::#{Jets.aws.account}:role/service-role/pre-created"
11
11
  # config.function.memory_size= 1536
12
12
  # config.function.cors = true
13
13
  config.function.environment = {
@@ -16,11 +16,6 @@ test:
16
16
  <<: *default
17
17
  database: <%= project_name %>_test
18
18
 
19
- staging:
20
- <<: *default
21
- database: <%= project_name %>_stag
22
- url: <%%= ENV['DATABASE_URL'] %>
23
-
24
19
  production:
25
20
  <<: *default
26
21
  database: <%= project_name %>_prod
@@ -18,8 +18,5 @@ test:
18
18
  endpoint: http://localhost:8000
19
19
  table_namespace: <%= Jets.config.table_namespace %>
20
20
 
21
- staging:
22
- table_namespace: <%= Jets.config.table_namespace %>
23
-
24
21
  production:
25
22
  table_namespace: <%= Jets.config.table_namespace %>
data/lib/jets/core.rb CHANGED
@@ -135,7 +135,7 @@ module Jets::Core
135
135
  .sub(/^\.\//,'') # remove ./
136
136
  .sub(/app\/\w+\//,'') # remove app/controllers or app/jobs etc
137
137
  .classify
138
- puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['DEBUG']
138
+ puts "eager_load! loading path: #{path} class_name: #{class_name}" if ENV['JETS_DEBUG']
139
139
  class_name.constantize # use constantize instead of require so dont have to worry about order.
140
140
  end
141
141
  end
data/lib/jets/erb.rb CHANGED
@@ -15,7 +15,7 @@ class Jets::Erb
15
15
  ERB.new(template, nil, "-").result(binding)
16
16
  rescue Exception => e
17
17
  puts e
18
- puts e.backtrace if ENV['DEBUG']
18
+ puts e.backtrace if ENV['JETS_DEBUG']
19
19
 
20
20
  # how to know where ERB stopped? - https://www.ruby-forum.com/topic/182051
21
21
  # syntax errors have the (erb):xxx info in e.message
@@ -42,6 +42,10 @@ module Jets::Lambda::Dsl
42
42
  class_properties(handler: name)
43
43
  end
44
44
 
45
+ def class_runtime(value)
46
+ class_properties(runtime: value)
47
+ end
48
+
45
49
  # convenience method that set properties
46
50
  def timeout(value)
47
51
  properties(timeout: value)
@@ -146,6 +150,12 @@ module Jets::Lambda::Dsl
146
150
  all_tasks.values
147
151
  end
148
152
 
153
+ # Used in Jets::Cfn::TemplateBuilders::Interface#build
154
+ # Overridden in rule/dsl.rb
155
+ def build?
156
+ !tasks.empty?
157
+ end
158
+
149
159
  # The public methods defined in the project app class ulimately become
150
160
  # lambda functions.
151
161
  #
data/lib/jets/rule.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  class Jets::Rule
2
- autoload :Dsl, "jets/rule/dsl"
2
+ autoload :AwsManagedRule, "jets/rule/aws_managed_rule"
3
3
  autoload :Base, "jets/rule/base"
4
+ autoload :Dsl, "jets/rule/dsl"
4
5
  autoload :Task, "jets/rule/task"
5
6
  end
@@ -0,0 +1,12 @@
1
+ class Jets::Rule::AwsManagedRule < Jets::Rule::Task
2
+ def config_rule_defaults
3
+ source_identifier = meth.to_s.upcase
4
+ {
5
+ "ConfigRuleName" => config_rule_name,
6
+ "Source" => {
7
+ "Owner" => "AWS",
8
+ "SourceIdentifier" => source_identifier
9
+ }
10
+ }
11
+ end
12
+ end
data/lib/jets/rule/dsl.rb CHANGED
@@ -41,7 +41,6 @@ module Jets::Rule::Dsl
41
41
  config_rule(maximum_execution_frequency: value)
42
42
  end
43
43
 
44
- # not really meant to be used but provided for completeness
45
44
  def source(value)
46
45
  config_rule(source: value)
47
46
  end
@@ -57,8 +56,36 @@ module Jets::Rule::Dsl
57
56
  def register_task(meth, lang=:ruby)
58
57
  all_tasks[meth] = Jets::Rule::Task.new(self.name, meth,
59
58
  properties: @properties, config_rule: @config_rule, lang: lang)
59
+ clear_properties
60
60
  true
61
61
  end
62
+
63
+ def clear_properties
64
+ super
65
+ @config_rule = nil
66
+ end
67
+
68
+ ## aws managed rules work different enough to merit their own storage
69
+
70
+ def all_managed_rules
71
+ @all_managed_rules ||= ActiveSupport::OrderedHash.new
72
+ end
73
+
74
+ def managed_rules
75
+ all_managed_rules.values
76
+ end
77
+
78
+ def managed_rule(meth)
79
+ all_managed_rules[meth] = Jets::Rule::AwsManagedRule.new(self.name, meth,
80
+ properties: @properties, config_rule: @config_rule)
81
+ clear_properties
82
+ true
83
+ end
84
+
85
+ # Override Lambda::Dsl.build? to account of possible managed_rules
86
+ def build?
87
+ !tasks.empty? || !managed_rules.empty?
88
+ end
62
89
  end
63
90
  end
64
91
  end
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
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: 0.6.8
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-26 00:00:00.000000000 Z
11
+ date: 2018-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -408,6 +408,7 @@ files:
408
408
  - Procfile
409
409
  - README.md
410
410
  - Rakefile
411
+ - bin/release
411
412
  - buildspec.yml
412
413
  - exe/jets
413
414
  - jets.gemspec
@@ -627,6 +628,7 @@ files:
627
628
  - lib/jets/router.rb
628
629
  - lib/jets/ruby_server.rb
629
630
  - lib/jets/rule.rb
631
+ - lib/jets/rule/aws_managed_rule.rb
630
632
  - lib/jets/rule/base.rb
631
633
  - lib/jets/rule/dsl.rb
632
634
  - lib/jets/rule/task.rb