Cloudformation 资源 creation/deleteion 超时期限
Cloudformation Resource creation/deleteion timeout period
在this tutorial中写着:
Set reasonable timeout periods, and report when they're about to be exceeded
If an operation doesn't execute within its defined timeout period, the
function raises an exception and no response is sent to
CloudFormation.
To avoid this, ensure that the timeout value for your Lambda functions
is set high enough to handle variations in processing time and network
conditions. Consider also setting a timer in your function to respond
to CloudFormation with an error when a function is about to time out;
this can help prevent function timeouts from causing custom resource
timeouts and delays.
这背后的确切解决方案是什么?我应该在 AWS Lambda 上实施超时吗
或者我可以在 CustomResource 属性中设置超时时间?
据我所知,您不能在 CustomResource 上设置超时。
他们在您的引文中写的是,您可以在函数超时之前向 Cloudformation 发出信号。
您可以通过查询处理函数中的第二个参数上下文对象来了解剩余时间。例如 Python:
def handler(event, context):
print("Time left:", context.get_remaining_time_in_millis())
您会看到其他语言的方法调用是相似的,例如 Java:
context.getRemainingTimeInMillis()
因此,您可以查询循环中的剩余时间,当该值变低(例如 3000 毫秒)时,检查您的资源是否仍未创建并向 Cloudformation 发送错误信号。
其次,按照他们的建议增加函数的超时时间。
在this tutorial中写着:
Set reasonable timeout periods, and report when they're about to be exceeded
If an operation doesn't execute within its defined timeout period, the function raises an exception and no response is sent to CloudFormation.
To avoid this, ensure that the timeout value for your Lambda functions is set high enough to handle variations in processing time and network conditions. Consider also setting a timer in your function to respond to CloudFormation with an error when a function is about to time out; this can help prevent function timeouts from causing custom resource timeouts and delays.
这背后的确切解决方案是什么?我应该在 AWS Lambda 上实施超时吗 或者我可以在 CustomResource 属性中设置超时时间?
据我所知,您不能在 CustomResource 上设置超时。 他们在您的引文中写的是,您可以在函数超时之前向 Cloudformation 发出信号。
您可以通过查询处理函数中的第二个参数上下文对象来了解剩余时间。例如 Python:
def handler(event, context):
print("Time left:", context.get_remaining_time_in_millis())
您会看到其他语言的方法调用是相似的,例如 Java:
context.getRemainingTimeInMillis()
因此,您可以查询循环中的剩余时间,当该值变低(例如 3000 毫秒)时,检查您的资源是否仍未创建并向 Cloudformation 发送错误信号。
其次,按照他们的建议增加函数的超时时间。