如何解决在 CloudFormation 中使用资源提供商类型创建资源时收到的“Resource timed out waiting for creation of physical resource”(等待创建物理资源时资源超时)错误?
上次更新日期:2022 年 9 月 19 日
当我使用我的资源提供商类型在 AWS CloudFormation 中创建资源时,我收到以下错误:
"Resource timed out waiting for creation of physical resource"(等待创建物理资源时资源超时)
简短描述
如果资源未在 60 秒内返回其 primaryIdentifier 或物理 ID,您将会收到"Resource timed out waiting for creation of physical resource"(等待创建物理资源时资源超时)这一错误。发生错误是因为,您的资源的 CreateHandler 未返回在organization-service-resource.json 资源提供者 schema 文件中被指定为 primaryIdentifier 的属性。
有关与使用资源提供商相关的其他错误,请参阅以下文章:
- 如何解决在 CloudFormation 中使用 CloudFormation CLI 运行 cfn generate 命令时收到的 "Resource specification is invalid"(资源规范无效)错误?
- 如何解决 CloudFormation 中的“Model validation failed (#: extraneous key [Key] is not permitted)”(模型验证失败 [#:不允许外键 [Key]]) 错误?
- 如何解决在 CloudFormation 中的资源提供商资源上使用 Fn::GetAtt 函数时收到的 Attribute 'Key' does not exist(属性“Key”不存在)错误?
- 如何解决 CloudFormation 中的"java.lang.ClassNotFoundException: com.example.package.resource.HandlerWrapper" 错误?
解决方法
1. 在您的organization-service-resource.json文件中,确认 primaryIdentifier 定义遵循的是此格式,其中,Id是在属性部分定义的:
"primaryIdentifier": [
"/properties/Id"
]
注意:organization-service-resource.json 格式位于项目的根目录中。
2. 在 CreateHandler中,在模型对象中设置primaryIdentifier属性。例如:
final ResourceModel model = request.getDesiredResourceState();
model.setId("abcdxyz");
return ProgressEvent.<ResourceModel, CallbackContext>builder()
.resourceModel(model)
.status(OperationStatus.SUCCESS)
.build();
相关信息
AWS CloudFormation CLI(来自GitHub 网站)