-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d672a15
commit 2147c21
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# DO NOT EDIT | ||
# Source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-lambda-function-code-cfnresponsemodule.html#cfn-lambda-function-code-cfnresponsemodule-source-python | ||
|
||
from __future__ import print_function | ||
import urllib3 # type: ignore | ||
import json | ||
|
||
SUCCESS = "SUCCESS" | ||
FAILED = "FAILED" | ||
|
||
http = urllib3.PoolManager() | ||
|
||
|
||
def send( | ||
event, | ||
context, | ||
responseStatus, | ||
responseData, | ||
physicalResourceId=None, | ||
noEcho=False, | ||
reason=None, | ||
): | ||
responseUrl = event["ResponseURL"] | ||
|
||
print(responseUrl) | ||
|
||
responseBody = { | ||
"Status": responseStatus, | ||
"Reason": reason | ||
or "See the details in CloudWatch Log Stream: {}".format( | ||
context.log_stream_name | ||
), | ||
"PhysicalResourceId": physicalResourceId or context.log_stream_name, | ||
"StackId": event["StackId"], | ||
"RequestId": event["RequestId"], | ||
"LogicalResourceId": event["LogicalResourceId"], | ||
"NoEcho": noEcho, | ||
"Data": responseData, | ||
} | ||
|
||
json_responseBody = json.dumps(responseBody) | ||
|
||
print("Response body:") | ||
print(json_responseBody) | ||
|
||
headers = {"content-type": "", "content-length": str(len(json_responseBody))} | ||
|
||
try: | ||
response = http.request( | ||
"PUT", responseUrl, headers=headers, body=json_responseBody | ||
) | ||
print("Status code:", response.status) | ||
|
||
except Exception as e: | ||
print("send(..) failed executing http.request(..):", e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters