lambda_deployment 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/lambda_deployment/client.rb +4 -0
- data/lib/lambda_deployment/configuration.rb +12 -1
- data/lib/lambda_deployment/lambda/deploy.rb +23 -0
- data/lib/lambda_deployment/version.rb +1 -1
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d8840ac60400c3a61e7bd801c9f3d53160eb5c1
|
4
|
+
data.tar.gz: e8796fa101bf6d505400f4da0ae260c3bc167d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e39da174345e0e56445d8111644ce055f3d93c67068c388e71e5c6feecb826ab1fbdc75c409310d65ac12a57c07c7041105e82ba8187b1d19e97c0f93cd0b083
|
7
|
+
data.tar.gz: c8eb26318070c5046495be0cfc0c96dec046bad9df9faa123f360fd4aa5c062d3541aff1abd5ec524b3904b28fe915378a21d26466a4f71e88cd320d93ee55ad
|
data/README.md
CHANGED
@@ -66,6 +66,8 @@ project: my-dev-lambda-name # required: name of lambda function
|
|
66
66
|
region: us-east-1 # optional: specify AWS region (will override $AWS_REGION)
|
67
67
|
s3_bucket: my-test-bucket # optional: specify s3 bucket (will override $LAMBDA_S3_BUCKET)
|
68
68
|
s3_sse: AES256 # optional: set server side encryption on s3 objects (will override $LAMBDA_S3_SSE)
|
69
|
+
environment:
|
70
|
+
FOO: bar # optional: set some env vars for your Lambda
|
69
71
|
```
|
70
72
|
|
71
73
|
* *file_name* is a path relative to the configuration file
|
@@ -1,6 +1,8 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
|
1
3
|
module LambdaDeployment
|
2
4
|
class Configuration
|
3
|
-
attr_reader :file_path, :project, :region, :s3_bucket, :s3_key, :s3_sse
|
5
|
+
attr_reader :kms_key_arn, :file_path, :project, :region, :s3_bucket, :s3_key, :s3_sse
|
4
6
|
|
5
7
|
def load_config(config_file)
|
6
8
|
config = YAML.load_file(config_file)
|
@@ -12,6 +14,9 @@ module LambdaDeployment
|
|
12
14
|
@s3_bucket = config.fetch('s3_bucket', ENV.fetch('LAMBDA_S3_BUCKET', nil))
|
13
15
|
@s3_key = s3_key_name(config.fetch('file_name'))
|
14
16
|
@s3_sse = config.fetch('s3_sse', ENV.fetch('LAMBDA_S3_SSE', nil))
|
17
|
+
|
18
|
+
@config_env = config.fetch('environment', {})
|
19
|
+
@kms_key_arn = config.fetch('kms_key_arn', ENV.fetch('LAMBDA_KMS_KEY_ARN', nil))
|
15
20
|
end
|
16
21
|
|
17
22
|
# lambda aliases must satisfy (?!^[0-9]+$)([a-zA-Z0-9-_]+)
|
@@ -22,6 +27,12 @@ module LambdaDeployment
|
|
22
27
|
tag
|
23
28
|
end
|
24
29
|
|
30
|
+
def environment
|
31
|
+
@environment_cache ||= Dir.glob('.env*').reduce({}) do |cache, filename|
|
32
|
+
cache.merge Dotenv::Environment.new(filename)
|
33
|
+
end.merge(@config_env)
|
34
|
+
end
|
35
|
+
|
25
36
|
private
|
26
37
|
|
27
38
|
def s3_key_name(file_name)
|
@@ -9,6 +9,7 @@ module LambdaDeployment
|
|
9
9
|
def run
|
10
10
|
upload_to_s3
|
11
11
|
update_function_code
|
12
|
+
update_environment
|
12
13
|
return unless @config.alias_name
|
13
14
|
version = publish_version
|
14
15
|
begin
|
@@ -37,6 +38,28 @@ module LambdaDeployment
|
|
37
38
|
)
|
38
39
|
end
|
39
40
|
|
41
|
+
def update_environment
|
42
|
+
environment = {}
|
43
|
+
@config.environment.map { |k, v| environment[k] = encrypt(v) }
|
44
|
+
@client.lambda_client.update_function_configuration(
|
45
|
+
function_name: @config.project,
|
46
|
+
kms_key_arn: @config.kms_key_arn,
|
47
|
+
environment: {
|
48
|
+
variables: environment
|
49
|
+
}
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def encrypt(value)
|
54
|
+
return value unless @config.kms_key_arn
|
55
|
+
Base64.encode64(
|
56
|
+
@client.kms_client.encrypt(
|
57
|
+
key_id: @config.kms_key_arn,
|
58
|
+
plaintext: value
|
59
|
+
).ciphertext_blob
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
40
63
|
def publish_version
|
41
64
|
@client.lambda_client.publish_version(
|
42
65
|
function_name: @config.project
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lambda_deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zendesk CloudOps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,34 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bump
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: forking_test_runner
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description:
|
70
112
|
email:
|
71
113
|
executables:
|
@@ -102,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
144
|
version: '0'
|
103
145
|
requirements: []
|
104
146
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.6.11
|
106
148
|
signing_key:
|
107
149
|
specification_version: 4
|
108
150
|
summary: Lambda Deployment Library
|