Need your help! From the API Gateway, I'm trying to trigger a Lambda function. This Lambda function is going to create a CloudFormation stack and the stack is in-turn going to deploy an EC2-instance. Below is part of the code that initiates the stack creation and waits for the stack creation status to be set to complete before it can return a response. Thing is API Gateway has an hard-coded timeout value of 30 seconds and the stack creation does not complete before 30 seconds. In this scenario, the API request just times-out returning an internal server error. How do I handle this?
# Create the CloudFormation Stack
StackID = cf_client.create_stack(
StackName=stackname,
TemplateURL='https://s3-bucket/template1.template',
Capabilities=['CAPABILITY_NAMED_IAM']
)
waiter = cf_client.get_waiter('stack_create_complete')
waiter.wait(
StackName=stackname,
WaiterConfig={
'Delay' : 5,
'MaxAttempts' : 50
}
)