cfnresponse 0.1.0 → 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/Gemfile.lock +35 -0
- data/README.md +3 -3
- data/lib/cfnresponse.rb +14 -11
- data/lib/cfnresponse/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05710e4604b1477e2d5fbbf30546871fdc1df8216a32dc176bd15b578460c14c
|
4
|
+
data.tar.gz: a09f8396d55782ddcf95ca8b79accd5832372976360a7f5734488731e3521b56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60111ac603fbcd18952d7324e358de232e058229e4dc7d5d702e434e5b4aa89e7a9b5614a64440347cbd7d6acb51caa18a219751ddfdacf888916c34f79eb8e6
|
7
|
+
data.tar.gz: a47d6a17949406e9562497a32dc45a444b3a7fdc40ef32b9356c8e0978b1a2e457cafe07bfba87babd75151e80b8fec2886af978b6b7f63ae4bd4cc25f1740a0
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cfnresponse (0.2.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.8.0)
|
12
|
+
rspec-core (~> 3.8.0)
|
13
|
+
rspec-expectations (~> 3.8.0)
|
14
|
+
rspec-mocks (~> 3.8.0)
|
15
|
+
rspec-core (3.8.0)
|
16
|
+
rspec-support (~> 3.8.0)
|
17
|
+
rspec-expectations (3.8.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.8.0)
|
20
|
+
rspec-mocks (3.8.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-support (3.8.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 2.0)
|
30
|
+
cfnresponse!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
2.0.1
|
data/README.md
CHANGED
@@ -30,13 +30,13 @@ def lambda_handler(event:, context:)
|
|
30
30
|
case event['RequestType']
|
31
31
|
when "Create"
|
32
32
|
# create logic
|
33
|
-
send_response(event, context, SUCCESS)
|
33
|
+
send_response(event, context, "SUCCESS")
|
34
34
|
when "Update"
|
35
35
|
# update logic
|
36
|
-
send_response(event, context, SUCCESS)
|
36
|
+
send_response(event, context, "SUCCESS")
|
37
37
|
when "Delete"
|
38
38
|
# delete logic
|
39
|
-
send_response(event, context, SUCCESS)
|
39
|
+
send_response(event, context, "SUCCESS")
|
40
40
|
end
|
41
41
|
|
42
42
|
sleep 10 # a little time for logs to be sent to CloudWatch
|
data/lib/cfnresponse.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "cfnresponse/version"
|
2
2
|
require "json"
|
3
|
+
require "net/http"
|
3
4
|
require "uri"
|
4
5
|
|
5
6
|
module Cfnresponse
|
@@ -9,18 +10,20 @@ module Cfnresponse
|
|
9
10
|
def send_response(event, context, response_status, response_data={}, physical_id="PhysicalId", reason=nil)
|
10
11
|
reason ||= "See the details in CloudWatch Log Stream: #{context.log_stream_name.inspect}"
|
11
12
|
|
12
|
-
|
13
|
-
Status
|
14
|
-
Reason
|
15
|
-
PhysicalResourceId
|
16
|
-
StackId
|
17
|
-
RequestId
|
18
|
-
LogicalResourceId
|
19
|
-
Data
|
20
|
-
|
13
|
+
body_data = {
|
14
|
+
"Status" => response_status,
|
15
|
+
"Reason" => reason,
|
16
|
+
"PhysicalResourceId" => physical_id,
|
17
|
+
"StackId" => event['StackId'],
|
18
|
+
"RequestId" => event['RequestId'],
|
19
|
+
"LogicalResourceId" => event['LogicalResourceId'],
|
20
|
+
"Data" => response_data
|
21
|
+
}
|
21
22
|
|
22
23
|
puts "Response body:\n"
|
23
|
-
puts json_pretty(
|
24
|
+
puts json_pretty(body_data)
|
25
|
+
|
26
|
+
response_body = JSON.dump(body_data) # response_body is a JSON string
|
24
27
|
|
25
28
|
url = event['ResponseURL']
|
26
29
|
uri = URI(url)
|
@@ -39,7 +42,7 @@ module Cfnresponse
|
|
39
42
|
|
40
43
|
if ENV['CFNRESPONSE_TEST']
|
41
44
|
puts "uri #{uri.inspect}"
|
42
|
-
return # early return to not send the request
|
45
|
+
return body_data # early return to not send the request
|
43
46
|
end
|
44
47
|
|
45
48
|
res = http.request(req)
|
data/lib/cfnresponse/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfnresponse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- ".rspec"
|
64
64
|
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
|
+
- Gemfile.lock
|
66
67
|
- LICENSE.txt
|
67
68
|
- README.md
|
68
69
|
- Rakefile
|