如何解决在 CloudFormation 中使用资源提供程序类型创建资源时出现的“资源在等待创建物理资源时超时”错误?

1 分钟阅读
0

当我使用我的资源提供程序类型在 AWS CloudFormation 中创建资源时,会收到以下错误: “资源在等待创建物理资源时超时。”

解决方法

当资源未在 60 秒内返回其 primaryIdentifierPhysical ID(物理 ID)时,您会收到错误“Resource timed out waiting for creation of physical resource”(资源在等待创建物理资源时超时)。之所以发生此错误,是因为您的资源的 CreateHandler 未返回在资源类型架构文件中指定为 primaryIdentifier 的属性。

**注意:**该文件使用 organization-service-resource.json 命名格式。例如,对于名为 Article::EC2::Subnet 的 Amazon Elastic Cloud Compute (Amazon EC2) 资源,文件名为 article-ec2-subnet.json

要解决此问题,请完成以下步骤:

  1. 在您的资源类型架构文件中,确认 primaryIdentifier 定义使用以下格式:
    "primaryIdentifier": [      
           "/properties/Id"
    ]
    **注意:**将 Id 替换为属性 ID。您可以在项目的根目录中找到资源架构类型文件。
  2. 在您的 CreateHandler 文件中,设置 model 对象中的 primaryIdentifier 属性。
    示例:
    final ResourceModel model = request.getDesiredResourceState();
    model.setId("abcdxyz");
    return ProgressEvent.<ResourceModel, CallbackContext>builder()
        .resourceModel(model)
        .status(OperationStatus.SUCCESS)
        .build();
    **注意:**将 Id 替换为资源的主要标识符,将 abcdxyz 替换为您的属性的唯一标识符值。

如果您在使用资源提供商时收到其他错误,请参阅以下 AWS Knowledge Center 文章进行故障排除:

相关信息

GitHub 网站上的 CloudFormation CLI

AWS 官方
AWS 官方已更新 2 个月前