lambda_wrap 0.17.0 → 0.18.0
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/lib/lambda_wrap/api_gateway_manager.rb +47 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54645cd0cccdaebbcf9a5896a97cd2d2ff4f2d1f
|
4
|
+
data.tar.gz: 30784484753973a0cdf72a3ae927054cea01feb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ec78d9a830806e6fc441786488eaea3653a26bda5d3184164b335d6e26f07221782c272a28ac691c5066ad8c927b60f5390acdf63cc949db732582c93849f80
|
7
|
+
data.tar.gz: 5ecb88c2ae50db5f518c7f571f61c443a66a4a36826986b01b52bab5f5888de744820356b94ffe84845b5a7f2ed878ec8edb8f4a20cb8207dfbde1cfc118e04d
|
@@ -3,7 +3,9 @@ require 'aws-sdk'
|
|
3
3
|
module LambdaWrap
|
4
4
|
# The ApiGatewayManager simplifies downloading the aws-apigateway-importer binary,
|
5
5
|
# importing a {swagger configuration}[http://swagger.io], and managing API Gateway stages.
|
6
|
-
|
6
|
+
# Added functionality to create APIGateway deom Swagger file. Thsi API is useful for gateway's having
|
7
|
+
#custom authorization.
|
8
|
+
|
7
9
|
# Note: The concept of an environment of the LambdaWrap gem matches a stage in AWS ApiGateway terms.
|
8
10
|
class ApiGatewayManager
|
9
11
|
#
|
@@ -151,7 +153,50 @@ module LambdaWrap
|
|
151
153
|
puts 'API Gateway stage ' + env + ' does not exist. Nothing to delete.'
|
152
154
|
end
|
153
155
|
end
|
154
|
-
|
156
|
+
|
157
|
+
# Generate or Update the API Gateway by using the swagger file.
|
158
|
+
# *Arguments*
|
159
|
+
# [api_name] API Gateway name
|
160
|
+
# [local_swagger_file] Path of the local swagger file
|
161
|
+
# [env] Environment
|
162
|
+
def setup_apigateway_by_swagger_file(api_name, local_swagger_file, env, stage_variables = {})
|
163
|
+
|
164
|
+
#If API gateway with the name is already present then update it else create a new one
|
165
|
+
api_id = get_existing_rest_api(api_name)
|
166
|
+
swagger_file_content = File.read(local_swagger_file)
|
167
|
+
|
168
|
+
gateway_response = nil
|
169
|
+
if (api_id.nil?)
|
170
|
+
#Create a new APIGateway
|
171
|
+
gateway_response = @client.import_rest_api(fail_on_warnings: false, body: swagger_file_content)
|
172
|
+
else
|
173
|
+
#Update the exsiting APIgateway. By Merge the exsisting gateway will be merged with the new one supplied in teh Swagger file.
|
174
|
+
gateway_response = @client.put_rest_api(rest_api_id: api_id, mode: 'merge', fail_on_warnings: false, body: swagger_file_content)
|
175
|
+
end
|
176
|
+
|
177
|
+
if (gateway_response.nil? && gateway_response.id.nil?)
|
178
|
+
raise "Failed to create API gateway with name #{api_name}"
|
179
|
+
else
|
180
|
+
if (api_id.nil?)
|
181
|
+
puts "Created api gateway #{api_name} having id #{gateway_response.id}"
|
182
|
+
else
|
183
|
+
puts "Updated api gateway #{api_name} having id #{gateway_response.id}"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
#Deploy the service
|
188
|
+
deployment_description = 'Deployment of service to ' + env
|
189
|
+
stage_variables.store('environment', env)
|
190
|
+
create_stages(gateway_response.id, env, stage_variables)
|
191
|
+
|
192
|
+
service_uri = "https://#{gateway_response.id}.execute-api.#{ENV['AWS_REGION']}.amazonaws.com/#{env}/"
|
193
|
+
puts "Service deployed at #{service_uri}"
|
194
|
+
|
195
|
+
return service_uri
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
|
155
200
|
private :get_existing_rest_api, :setup_apigateway_create_rest_api, :setup_apigateway_create_resources,
|
156
201
|
:create_stages, :delete_stage
|
157
202
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lambda_wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Thurner
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-08-
|
13
|
+
date: 2016-08-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|