addy_lambda 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +2 -0
- data/addy_lambda-0.1.0.gem +0 -0
- data/addy_lambda-0.1.1.gem +0 -0
- data/addy_lambda.gemspec +3 -0
- data/lib/addy_lambda/aws.rb +13 -0
- data/lib/addy_lambda/common.rb +25 -0
- data/lib/addy_lambda/version.rb +1 -1
- metadata +46 -3
- data/deleteme.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e813edb9e46e1f1c6e7af77819d0f5ac1b313b99b0ba0c4d26bb729ba749068
|
4
|
+
data.tar.gz: 1fc81b2cfb959e294c46a42abdf11c2c92f1bd6615da4b98de9f9361ad322090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 490b1703c07468e6d331d83dd0d37013a9ee2d8645cc2ff47686230d02fe2f80c6f74828cfa149f762069ae6a5152553fe45d6e93959fc6ffd88e9f5431485e3
|
7
|
+
data.tar.gz: b22cdc6f22d90019eec62d3ff9abaf6b734cd5ef6c89d55a3f0bc3777e3cf09b716f1f0a35884c1b771078d1d07cb83885ef1780f7fe55b20ce1c8f9da1abcba
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -33,6 +33,8 @@ Or install it yourself as:
|
|
33
33
|
- Make your changes
|
34
34
|
- Bump the version in `lib/addy_lambda/version.rb`
|
35
35
|
- Build using `gem build addy_lambda.gemspec`
|
36
|
+
- Run (this needs to happen once) `curl -u addydev https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials`
|
37
|
+
- gem push addy_lambda-<version>.gem
|
36
38
|
|
37
39
|
## Usage
|
38
40
|
|
Binary file
|
Binary file
|
data/addy_lambda.gemspec
CHANGED
@@ -26,6 +26,9 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.bindir = 'exe'
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
|
+
spec.add_dependency 'aws-sdk-lambda'
|
30
|
+
spec.add_dependency 'aws-sdk-s3'
|
31
|
+
spec.add_dependency 'aws-sdk-sns'
|
29
32
|
spec.add_dependency 'aws-sdk-ssm'
|
30
33
|
spec.add_dependency 'thor'
|
31
34
|
end
|
data/lib/addy_lambda/aws.rb
CHANGED
@@ -51,6 +51,19 @@ module AddyLambda
|
|
51
51
|
logger.error(response_body['error'])
|
52
52
|
end
|
53
53
|
|
54
|
+
# s3_client = Aws::S3::Client.new
|
55
|
+
def self.copy_file_from_s3(s3_client, bucket, key, destination)
|
56
|
+
s3_client.get_object({ bucket: bucket, key: key }, target: destination)
|
57
|
+
end
|
58
|
+
|
59
|
+
# s3_client = Aws::S3::Client.new
|
60
|
+
def self.save_file_to_s3(s3_client, file_location, bucket, key)
|
61
|
+
# Upload
|
62
|
+
File.open(file_location, 'rb') do |file|
|
63
|
+
s3_client.put_object(bucket: bucket, key: key, body: file)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
54
67
|
def self.send_email(lambda_client, recipient_emails, from_name, from_email, subject, content_html)
|
55
68
|
input_params = {
|
56
69
|
'recipient_list' => recipient_emails,
|
data/lib/addy_lambda/common.rb
CHANGED
@@ -3,6 +3,8 @@ require 'json'
|
|
3
3
|
module AddyLambda
|
4
4
|
# Generic methods such as logging, error handling HTTP requests etc.
|
5
5
|
class Common
|
6
|
+
VARIABLE_DIRECT = 'direct'.freeze
|
7
|
+
|
6
8
|
def self.generic_log(logger, event, context)
|
7
9
|
logger.debug('## EVENT')
|
8
10
|
logger.debug(event.inspect)
|
@@ -10,6 +12,29 @@ module AddyLambda
|
|
10
12
|
logger.debug(context.inspect)
|
11
13
|
end
|
12
14
|
|
15
|
+
def self.get_body_as_object(event)
|
16
|
+
body_as_object = {}
|
17
|
+
|
18
|
+
if event.key?('body') and event['body'].is_a? String
|
19
|
+
body_as_object = JSON.parse(event['body'])
|
20
|
+
elsif event.key?('body')
|
21
|
+
body_as_object = event['body']
|
22
|
+
end
|
23
|
+
|
24
|
+
body_as_object
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.get_parameter(event, parameter, type, default_value = nil)
|
28
|
+
event_body = get_body_as_object(event)
|
29
|
+
|
30
|
+
case type
|
31
|
+
when VARIABLE_DIRECT
|
32
|
+
event_body.fetch(parameter, default_value)
|
33
|
+
else
|
34
|
+
default_value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
13
38
|
# sns = Aws::SNS::Resource.new(region: region)
|
14
39
|
def self.handle_error(sns, logger, error, context)
|
15
40
|
region = context.invoked_function_arn.split(':')[3]
|
data/lib/addy_lambda/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addy_lambda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alon Sabi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk-lambda
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk-s3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk-sns
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: aws-sdk-ssm
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,8 +96,9 @@ files:
|
|
54
96
|
- LICENSE.txt
|
55
97
|
- README.md
|
56
98
|
- Rakefile
|
99
|
+
- addy_lambda-0.1.0.gem
|
100
|
+
- addy_lambda-0.1.1.gem
|
57
101
|
- addy_lambda.gemspec
|
58
|
-
- deleteme.rb
|
59
102
|
- lib/addy_lambda.rb
|
60
103
|
- lib/addy_lambda/aws.rb
|
61
104
|
- lib/addy_lambda/common.rb
|
data/deleteme.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative 'lib/addy_lambda'
|
2
|
-
|
3
|
-
lambda_client = Aws::Lambda::Client.new
|
4
|
-
|
5
|
-
# resp = AddyLambda::AWS.send_email(lambda_client, ['alon@sabi.me', 'alon@addyinvest.com'], 'alon', 'alon@addyinvest.com',
|
6
|
-
# 'This is the subject', 'This is the content')
|
7
|
-
|
8
|
-
# resp = AddyLambda::AWS.post_slack_message(lambda_client, '@alon', 'This is the mess', ':tada:')
|
9
|
-
|
10
|
-
# pdf_annotate / subscription
|
11
|
-
resp = AddyLambda::AWS.generate_jwt(lambda_client, AddyLambda::JwtIssuers::ADDY, AddyLambda::JwtAudiences::GENERIC,
|
12
|
-
3000, { 'alon' => 'sabi' })
|
13
|
-
# resp = AddyLambda::AWS.validate_jwt(lambda_client,
|
14
|
-
# 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhbG9uIjoic2FiaSIsImlzcyI6ImFkZHkiLCJhdWQiOiJnZW5lcmljIiwiaWF0IjoxNjM5NDQxMzk5LCJleHAiOjE2Mzk0NDQzOTl9.jj2OhiEZnJ9s6tamHdc0wGNzlgW3Jwq-S8YquTxe_JWhHuOZKYUhlCM1J1AtaLBqwbnFONCI1geK6cDXIA57lwikh2GcBZGecFfn3hq5IuoSqkhSW-PypTsw2dVCPX-W-qOj6ktbVkTU-d9NvTJJAR4nkJdQMBFtDDgMP_huzxldUjkV9i4ruiebev9blinLuwS_pHIOeqpnTkqRxQ9U6oZscYT8dxHUVoTG03_1dbnnfq3xoBjmBzENz9j2CtZO_fnM96iwqPR4EfxpM7TU7o9NxIzunmN4_Z6Jmjh5yQWpRSp5ItnqQ5N9m6a5bE3NyGDfJh3tVHs7wg3VNqxsLQ')
|
15
|
-
puts(resp)
|