jets 0.8.8 → 0.8.9
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +2 -2
- data/lib/jets/lambda/dsl.rb +54 -47
- data/lib/jets/resource/permission.rb +18 -39
- data/lib/jets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce580a14e5051954606f507aa2a9f4edcca4930045970966762d8ceb9857c814
|
4
|
+
data.tar.gz: da3d1d6d89c829ee6c28b9808f45c4db6b648925502f20164a725a5ad2acc59f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a77865cdc7eea19c9bbfb7a82d33c1196c9dbfdb29a990c5c5e268cd9cb3c4dc569d59fe88be10f0ad68b59af9800ed7809fede94f691d4a8e10763af46ea90
|
7
|
+
data.tar.gz: b1fab039f595fa5555d4239499868d66d9e1ed72f007c7e9f0fa10bb85fadb41c4cb26e470eedd839f42bd5fcb7da8412a069c5a658e49f004ccc5544178c4a5
|
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.8.9]
|
7
|
+
- clean up convenience properties and add rest of them PR #24
|
8
|
+
|
6
9
|
## [0.8.8]
|
7
10
|
- fix cron expression
|
8
11
|
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,7 @@ GIT
|
|
11
11
|
PATH
|
12
12
|
remote: .
|
13
13
|
specs:
|
14
|
-
jets (0.8.
|
14
|
+
jets (0.8.9)
|
15
15
|
actionpack (>= 5.2.1)
|
16
16
|
actionview (>= 5.2.1)
|
17
17
|
activerecord (>= 5.2.1)
|
@@ -69,7 +69,7 @@ GEM
|
|
69
69
|
aws-sdk-cloudformation (1.8.0)
|
70
70
|
aws-sdk-core (~> 3, >= 3.26.0)
|
71
71
|
aws-sigv4 (~> 1.0)
|
72
|
-
aws-sdk-cloudwatchlogs (1.
|
72
|
+
aws-sdk-cloudwatchlogs (1.8.0)
|
73
73
|
aws-sdk-core (~> 3, >= 3.26.0)
|
74
74
|
aws-sigv4 (~> 1.0)
|
75
75
|
aws-sdk-core (3.27.0)
|
data/lib/jets/lambda/dsl.rb
CHANGED
@@ -19,68 +19,75 @@ module Jets::Lambda::Dsl
|
|
19
19
|
end
|
20
20
|
alias_method :class_props, :class_properties
|
21
21
|
|
22
|
-
def
|
23
|
-
|
22
|
+
def properties(options={})
|
23
|
+
@properties ||= {}
|
24
|
+
@properties.deep_merge!(options)
|
24
25
|
end
|
26
|
+
alias_method :props, :properties
|
25
27
|
|
26
28
|
def class_environment(hash)
|
27
|
-
environment =
|
28
|
-
environment[:variables] ||= {}
|
29
|
-
environment[:variables].merge!(hash)
|
29
|
+
environment = standardize_env(hash)
|
30
30
|
class_properties(environment: environment)
|
31
31
|
end
|
32
32
|
alias_method :class_env, :class_environment
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
alias_method :class_memory, :class_memory_size
|
38
|
-
|
39
|
-
def class_role(name)
|
40
|
-
class_properties(role: name)
|
41
|
-
end
|
42
|
-
|
43
|
-
def class_handler(name)
|
44
|
-
class_properties(handler: name)
|
34
|
+
def environment(hash)
|
35
|
+
environment = standardize_env(hash)
|
36
|
+
properties(environment: environment)
|
45
37
|
end
|
38
|
+
alias_method :env, :environment
|
46
39
|
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
# Allows user to pass in hash with or without the :variables key.
|
41
|
+
def standardize_env(hash)
|
42
|
+
return hash if hash.key?(:variables)
|
50
43
|
|
51
|
-
# convenience method that set properties
|
52
|
-
def timeout(value)
|
53
|
-
properties(timeout: value)
|
54
|
-
end
|
55
|
-
|
56
|
-
# convenience method that set properties
|
57
|
-
def environment(hash)
|
58
44
|
environment = {}
|
59
45
|
environment[:variables] ||= {}
|
60
46
|
environment[:variables].merge!(hash)
|
61
|
-
|
47
|
+
environment
|
62
48
|
end
|
63
|
-
alias_method :env, :environment
|
64
49
|
|
65
|
-
#
|
66
|
-
|
67
|
-
|
50
|
+
# Convenience method that set properties. List based on https://amzn.to/2oSph1P
|
51
|
+
# Not all properites are included because some properties are not meant to be set
|
52
|
+
# directly. For example, function_name is a calculated setting by Jets.
|
53
|
+
PROPERTIES = %W[
|
54
|
+
dead_letter_config
|
55
|
+
description
|
56
|
+
handler
|
57
|
+
kms_key_arn
|
58
|
+
memory_size
|
59
|
+
reserved_concurrent_executions
|
60
|
+
role
|
61
|
+
runtime
|
62
|
+
timeout
|
63
|
+
tracing_config
|
64
|
+
vpc_config
|
65
|
+
tags
|
66
|
+
]
|
67
|
+
PROPERTIES.each do |property|
|
68
|
+
# Example:
|
69
|
+
# def timeout(value)
|
70
|
+
# properties(timeout: value)
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# def class_timeout(value)
|
74
|
+
# class_properties(timeout: value)
|
75
|
+
# end
|
76
|
+
class_eval <<~CODE
|
77
|
+
def #{property}(value)
|
78
|
+
properties(#{property}: value)
|
79
|
+
end
|
80
|
+
|
81
|
+
def class_#{property}(value)
|
82
|
+
class_properties(#{property}: value)
|
83
|
+
end
|
84
|
+
CODE
|
68
85
|
end
|
86
|
+
# More convenience aliases
|
69
87
|
alias_method :memory, :memory_size
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
def runtime(value)
|
76
|
-
properties(runtime: value)
|
77
|
-
end
|
78
|
-
|
79
|
-
def properties(options={})
|
80
|
-
@properties ||= {}
|
81
|
-
@properties.deep_merge!(options)
|
82
|
-
end
|
83
|
-
alias_method :props, :properties
|
88
|
+
alias_method :class_memory, :class_memory_size
|
89
|
+
alias_method :desc, :description
|
90
|
+
alias_method :class_desc, :class_description
|
84
91
|
|
85
92
|
# definitions: one or more definitions
|
86
93
|
def iam_policy(*definitions)
|
@@ -123,8 +130,8 @@ module Jets::Lambda::Dsl
|
|
123
130
|
end
|
124
131
|
|
125
132
|
#############################
|
126
|
-
#
|
127
|
-
#
|
133
|
+
# Main methood that registers resources associated with the Lambda function.
|
134
|
+
# All resources methods lead here.
|
128
135
|
def resources(*definitions)
|
129
136
|
if definitions == [nil] # when resources called with no arguments
|
130
137
|
@resources || []
|
@@ -1,46 +1,30 @@
|
|
1
1
|
class Jets::Resource
|
2
|
-
class Permission
|
3
|
-
extend Memoist
|
4
|
-
|
2
|
+
class Permission < Jets::Resource::Base
|
5
3
|
def initialize(replacements, associated_resource)
|
6
4
|
@replacements = replacements
|
7
|
-
# puts caller
|
8
|
-
# puts "replacements #{replacements.inspect}"
|
9
5
|
@associated_resource = associated_resource
|
10
6
|
end
|
11
7
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def type
|
23
|
-
attributes['Type']
|
24
|
-
end
|
25
|
-
|
26
|
-
def properties
|
27
|
-
attributes['Properties']
|
28
|
-
end
|
29
|
-
|
30
|
-
def attributes
|
31
|
-
attributes = {
|
32
|
-
type: "AWS::Lambda::Permission",
|
33
|
-
properties: {
|
34
|
-
function_name: "!GetAtt {namespace}LambdaFunction.Arn",
|
35
|
-
action: "lambda:InvokeFunction",
|
36
|
-
principal: principal,
|
37
|
-
source_arn: source_arn,
|
8
|
+
def definition
|
9
|
+
{
|
10
|
+
permission_logical_id => {
|
11
|
+
type: "AWS::Lambda::Permission",
|
12
|
+
properties: {
|
13
|
+
function_name: "!GetAtt {namespace}LambdaFunction.Arn",
|
14
|
+
action: "lambda:InvokeFunction",
|
15
|
+
principal: principal,
|
16
|
+
source_arn: source_arn,
|
17
|
+
}
|
38
18
|
}
|
39
19
|
}
|
40
|
-
attributes = replacer.replace_placeholders(attributes)
|
41
|
-
Jets::Camelizer.transform(attributes)
|
42
20
|
end
|
43
|
-
|
21
|
+
|
22
|
+
def permission_logical_id
|
23
|
+
logical_id = "{namespace}_permission"
|
24
|
+
md = @associated_resource.logical_id.match(/(\d+)/)
|
25
|
+
counter = md[1] if md
|
26
|
+
[logical_id, counter].compact.join('').underscore
|
27
|
+
end
|
44
28
|
|
45
29
|
# Auto-detect principal from the associated resources.
|
46
30
|
def principal
|
@@ -51,10 +35,5 @@ class Jets::Resource
|
|
51
35
|
default_arn = "!GetAtt #{@associated_resource.logical_id}.Arn"
|
52
36
|
Replacer.source_arn_map(@associated_resource.type) || default_arn
|
53
37
|
end
|
54
|
-
|
55
|
-
def replacer
|
56
|
-
Replacer.new(@replacements)
|
57
|
-
end
|
58
|
-
memoize :replacer
|
59
38
|
end
|
60
39
|
end
|
data/lib/jets/version.rb
CHANGED
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.8.
|
4
|
+
version: 0.8.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-09-
|
11
|
+
date: 2018-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|