lambda_deployment 0.5.0 → 0.6.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 +5 -2
- data/lib/lambda_deployment/configuration.rb +8 -4
- data/lib/lambda_deployment/lambda/deploy.rb +17 -0
- data/lib/lambda_deployment/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37d0c90c14da9606fbaa83f992feccc843adb8cd202c9aa7578ccc825e37c0c5
|
4
|
+
data.tar.gz: 1c628ca0791ca7a218afdf09fea58448e12c4791819e3cc3ba8df15d2cfa00bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcdac3890b938bf74568b268ee6ee1199426fa1e48d99047aa9e3922e3a2f60dbd97d86f714df51b296b021de5ee90caadb81de9477f23eb4cb663167bd571f5
|
7
|
+
data.tar.gz: cd09845e1ea8231fb79c271d9c5a53c81292fb1d193ee76f1e345b74755c9fa8d63f6c65a3e5a5cda4f003987da7ba12162a03491cd697f2930d694d61ff5e4f
|
data/README.md
CHANGED
@@ -14,7 +14,8 @@ lambda_deploy [-c path/to/configuration.yml] deploy|release
|
|
14
14
|
```
|
15
15
|
|
16
16
|
### Deploy action
|
17
|
-
The deploy action will upload the function to S3,
|
17
|
+
The deploy action will upload the function to S3, unless the `SKIP_UPLOAD`
|
18
|
+
environment variable is set to `true`. It will then update the function to
|
18
19
|
use the new code. If the environmental variable `TAG` is set it will also
|
19
20
|
create a version and link that version to an alias named `TAG`.
|
20
21
|
|
@@ -71,7 +72,9 @@ environment:
|
|
71
72
|
FOO: bar # optional: set some env vars for your Lambda
|
72
73
|
```
|
73
74
|
|
74
|
-
* *file_name* is
|
75
|
+
* *file_name* is the file_name needs to be the path relative to the configuration file.
|
76
|
+
It is also used, together with the TAG to generate the S3 key, not that the path, if any will not
|
77
|
+
be part of the key. So 'dist/lambda.zip' will result in a S3 key such as 'lambda-v3.zip'.
|
75
78
|
* *project* must match the function name in the AWS console (the last value in
|
76
79
|
the following example):
|
77
80
|
```
|
@@ -2,19 +2,23 @@ require 'dotenv'
|
|
2
2
|
|
3
3
|
module LambdaDeployment
|
4
4
|
class Configuration
|
5
|
-
attr_reader :concurrency, :kms_key_arn, :file_path, :project, :region, :s3_bucket, :s3_key, :s3_sse
|
5
|
+
attr_reader :concurrency, :kms_key_arn, :file_path, :project, :region, :s3_bucket, :s3_key, :s3_sse, :skip_upload
|
6
6
|
|
7
7
|
def load_config(config_file)
|
8
8
|
config = YAML.load_file(config_file)
|
9
|
+
@skip_upload = ENV.fetch('SKIP_UPLOAD', 'false') == 'true'
|
9
10
|
@project = config.fetch('project')
|
10
11
|
@region = config.fetch('region', ENV.fetch('AWS_REGION', nil))
|
11
|
-
@file_path = File.expand_path(config.fetch('file_name'), File.dirname(config_file))
|
12
|
-
raise "File not found: #{@file_path}" unless File.exist?(@file_path)
|
13
12
|
|
14
|
-
@s3_bucket = config.fetch('s3_bucket', ENV.fetch('LAMBDA_S3_BUCKET', nil))
|
15
13
|
@s3_key = s3_key_name(config.fetch('file_name'))
|
14
|
+
@s3_bucket = config.fetch('s3_bucket', ENV.fetch('LAMBDA_S3_BUCKET', nil))
|
16
15
|
@s3_sse = config.fetch('s3_sse', ENV.fetch('LAMBDA_S3_SSE', nil))
|
17
16
|
|
17
|
+
unless @skip_upload
|
18
|
+
@file_path = File.expand_path(config.fetch('file_name'), File.dirname(config_file))
|
19
|
+
raise "File not found: #{@file_path}" unless File.exist?(@file_path)
|
20
|
+
end
|
21
|
+
|
18
22
|
@config_env = config.fetch('environment', {})
|
19
23
|
@kms_key_arn = config.fetch('kms_key_arn', ENV.fetch('LAMBDA_KMS_KEY_ARN', nil))
|
20
24
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module LambdaDeployment
|
2
2
|
module Lambda
|
3
3
|
class Deploy
|
4
|
+
class ArchiveMissingError < StandardError ; end
|
5
|
+
|
4
6
|
def initialize(config)
|
5
7
|
@config = config
|
6
8
|
@client = LambdaDeployment::Client.new(config.region)
|
@@ -23,6 +25,8 @@ module LambdaDeployment
|
|
23
25
|
private
|
24
26
|
|
25
27
|
def upload_to_s3
|
28
|
+
return if @config.skip_upload
|
29
|
+
|
26
30
|
@client.s3_client.put_object(
|
27
31
|
body: File.read(@config.file_path),
|
28
32
|
bucket: @config.s3_bucket,
|
@@ -31,7 +35,20 @@ module LambdaDeployment
|
|
31
35
|
)
|
32
36
|
end
|
33
37
|
|
38
|
+
def code_exists_on_s3?
|
39
|
+
@client.s3_client.head_object(
|
40
|
+
bucket: @config.s3_bucket,
|
41
|
+
key: @config.s3_key
|
42
|
+
)
|
43
|
+
|
44
|
+
true
|
45
|
+
rescue Aws::S3::Errors::NotFound
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
34
49
|
def update_function_code
|
50
|
+
raise ArchiveMissingError.new("Could not find an archive on #{@config.s3_bucket} with the key #{@config.s3_key}") unless code_exists_on_s3?
|
51
|
+
|
35
52
|
@client.lambda_client.update_function_code(
|
36
53
|
function_name: @config.project,
|
37
54
|
s3_bucket: @config.s3_bucket,
|
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.6.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: 2018-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-kms
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rubocop
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|