删除 - Amazon CloudFormation
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

删除

当 template developer 删除包含自定义资源的堆栈时,将发送 RequestType 设置为 Delete 的自定义资源提供程序请求。要成功删除带自定义资源的堆栈,custom resource provider 必须成功响应删除请求。

请求

删除请求包含以下字段:

RequestType

Delete.

RequestId

请求的唯一 ID。

ResponseURL

响应 URL 标识一个预签名 S3 桶,该桶接收从自定义资源提供商到 Amazon CloudFormation 的响应。

ResourceType

Amazon CloudFormation 模板中模板开发人员选择的自定义资源的资源类型。自定义资源类型名称的长度最多为 60 个字符,并且可包含字母数字字符和以下字符:_@-

LogicalResourceId

Amazon CloudFormation 模板中模板开发人员选择的自定义资源的名称(逻辑 ID)。

StackId

标识包含自定义资源的堆栈的 Amazon 资源名称(ARN)。

PhysicalResourceId

custom resource provider 定义的必需物理 ID,该 ID 对于该提供程序是唯一的。

PhysicalResourceId 返回的值可以更改自定义资源更新操作。如果返回的值相同,则将其视为正常更新。如返回的值不同,则 Amazon CloudFormation 将该更新视为替换,并向旧资源发送删除请求。有关更多信息,请参阅AWS::CloudFormation::CustomResource

ResourceProperties

此字段包含模板开发人员发送的 Properties 对象的内容。其内容由自定义资源提供商定义。

示例

{
   "RequestType" : "Delete",
   "RequestId" : "unique id for this delete request",
   "ResponseURL" : "pre-signed-url-for-delete-response",
   "ResourceType" : "Custom::MyCustomResourceType",
   "LogicalResourceId" : "name of resource in template",
   "StackId" : "arn:aws:cloudformation:us-east-2:namespace:stack/stack-name/guid",
   "PhysicalResourceId" : "custom resource provider-defined physical id",
   "ResourceProperties" : {
      "key1" : "string",
      "key2" : [ "list" ],
      "key3" : { "key4" : "map" }
   }
}

响应

成功

删除请求成功时,必须向 S3 存储桶发送包含以下字段的响应:

Status

必须是 SUCCESS

RequestId

请求的唯一 ID。应从该请求逐字复制此响应值。

LogicalResourceId

Amazon CloudFormation 模板中模板开发人员选择的自定义资源的名称(逻辑 ID)。应从该请求逐字复制此响应值。

StackId

标识包含自定义资源的堆栈的 Amazon 资源名称(ARN)。应从该请求逐字复制此响应值。

PhysicalResourceId

该值应该为自定义资源供应商的唯一标识符,并且最大为 1KB。该值必须为非空字符串,并且对于同一资源的所有响应都必须相同。

PhysicalResourceId 返回的值可以更改自定义资源更新操作。如果返回的值相同,则将其视为正常更新。如返回的值不同,则 Amazon CloudFormation 将该更新视为替换,并向旧资源发送删除请求。有关更多信息,请参阅AWS::CloudFormation::CustomResource

示例

{
   "Status" : "SUCCESS",
   "RequestId" : "unique id for this delete request (copied from request)",
   "LogicalResourceId" : "name of resource in template (copied from request)",
   "StackId" : "arn:aws:cloudformation:us-east-2:namespace:stack/stack-name/guid (copied from request)",
   "PhysicalResourceId" : "custom resource provider-defined physical id"
}

失败

删除请求失败时,必须向 S3 存储桶发送包含以下字段的响应:

Status

必须是 FAILED

Reason

失败的原因。

RequestId

RequestId删除请求复制的 值。

LogicalResourceId

LogicalResourceId删除请求复制的 值。

StackId

StackId删除请求复制的 值。

PhysicalResourceId

自定义资源提供商定义的、对于该提供商唯一的必需物理 ID。

示例

{ "Status" : "FAILED", "Reason" : "Required failure reason string", "RequestId" : "unique id for this delete request (copied from request)", "LogicalResourceId" : "name of resource in template (copied from request)", "StackId" : "arn:aws:cloudformation:us-east-2:namespace:stack/stack-name/guid (copied from request)", "PhysicalResourceId" : "custom resource provider-defined physical id" }