Created
March 31, 2023 19:23
-
-
Save atedja/09d155645a188e32d47ab0fb7f7ad95c to your computer and use it in GitHub Desktop.
Manually resolve custom CloudFormation resource
This file contains hidden or 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
import json | |
from urllib.request import Request, urlopen | |
print(f"Copy-paste the JSON received by the custom resource lambda") | |
line = input() | |
event = json.loads(line) | |
r = json.dumps({ | |
'Status': 'SUCCESS', | |
'Reason': 'Forced', | |
'PhysicalResourceId': event['LogicalResourceId'], | |
'StackId': event['StackId'], | |
'RequestId': event['RequestId'], | |
'LogicalResourceId': event['LogicalResourceId'], | |
'Data': { 'Message': 'Forced' } | |
}) | |
d = str.encode(r) | |
headers = { | |
'Content-Type': '', | |
'Content-Length': str(len(d)) | |
} | |
req = Request(method='PUT', event['ResponseURL'], headers=headers, data=d) | |
resp = urlopen(req) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment