Delete - AWS CloudFormation

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Delete

當範本開發人員刪除堆疊或從堆疊中移除自訂資源時, CloudFormation 會將要求傳送至RequestType設定為的自訂資源提供者Delete。若要成功刪除含自訂資源的堆疊,custom resource provider 必須成功回應刪除請求。

如需自訂資源及其運作方式的簡介,請參閱自訂資源

請求

刪除包含以下欄位的請求:

RequestType

Delete.

RequestId

請求的唯一 ID。

ResponseURL

回應 URL 可識別從自訂資源提供者接收回應的預先簽署 S3 儲存貯體。 AWS CloudFormation

ResourceType

範本開發人員在範本中選擇的自訂資源類型。 CloudFormation 自訂資源類型名稱的長度上限為 60 個字元,且可包含英數字元及以下字元:_@-

LogicalResourceId

AWS CloudFormation 範本內由範本開發人員選擇之自訂資源的名稱 (邏輯 ID)。

StackId

識別包含自訂資源之堆疊的 Amazon Resource Name (ARN)。

PhysicalResourceId

提供者專屬的 custom resource provider 定義之必要的實體 ID。

傳回的 PhysicalResourceId 值可以變更自訂資源更新操作。如果傳回的值相同,則視為正常更新。如果傳回的值不同,請將更新 AWS 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-west-2:123456789012:stack/mystack/5b918d10-cd98-11ea-90d5-0a9cd3354c10", "PhysicalResourceId" : "custom resource provider-defined physical id", "ResourceProperties" : { "key1" : "string", "key2" : [ "list" ], "key3" : { "key4" : "map" } } }

回應

Success (成功)

當刪除請求成功時,必須將回應傳送到有下列欄位的 S3 儲存貯體:

Status

必須為 SUCCESS

RequestId

請求的唯一 ID。此回應值應從請求中逐字複製。

LogicalResourceId

AWS CloudFormation 範本內由範本開發人員選擇之自訂資源的名稱 (邏輯 ID)。此回應值應從請求中逐字複製。

StackId

識別包含自訂資源之堆疊的 Amazon Resource Name (ARN)。此回應值應從請求中逐字複製。

PhysicalResourceId

此值應為自訂資源廠商的唯一識別碼,且大小上限為 1 KB。此值必須是非空白字串,並且對於相同資源的所有回應必須完全相同。

傳回的 PhysicalResourceId 值可以變更自訂資源更新操作。如果傳回的值相同,則視為正常更新。如果傳回的值不同,請將更新 AWS 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-west-2:123456789012:stack/mystack/5b918d10-cd98-11ea-90d5-0a9cd3354c10 (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-west-2:123456789012:stack/mystack/5b918d10-cd98-11ea-90d5-0a9cd3354c10 (copied from request)", "PhysicalResourceId" : "custom resource provider-defined physical id" }