Skip to content

Instantly share code, notes, and snippets.

@atedja
Created March 31, 2023 19:23
Show Gist options
  • Save atedja/09d155645a188e32d47ab0fb7f7ad95c to your computer and use it in GitHub Desktop.
Save atedja/09d155645a188e32d47ab0fb7f7ad95c to your computer and use it in GitHub Desktop.
Manually resolve custom CloudFormation resource
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