Create
当 template developer 创建包含自定义资源的堆栈时,将发送 RequestType 已设置为 Create 的自定义资源提供者请求。
请求
创建请求包含以下字段:
- RequestType
-
Create。 - RequestId
-
请求的唯一 ID。
- ResponseURL
-
响应 URL 标识预签名的 S3 存储桶,该存储桶接收 custom resource provider 到 Amazon CloudFormation 的响应。
- ResourceType
-
Amazon CloudFormation 模板中模板开发人员选择的自定义资源的资源类型。自定义资源类型名称的长度最多为 60 个字符,并且可包含字母数字字符和以下字符:
_@-。 - LogicalResourceId
-
Amazon CloudFormation 模板中 template developer 选择的自定义资源名称(逻辑 ID)。
- StackId
-
标识包含自定义资源的堆栈的 Amazon 资源名称 (ARN)。
- ResourceProperties
-
该字段包含 template developer 发送的
Properties对象的内容。其内容由 custom resource provider 定义。
示例
{
"RequestType" : "Create",
"RequestId" : "unique id for this create request",
"ResponseURL" : "pre-signed-url-for-create-response",
"ResourceType" : "Custom::MyCustomResourceType",
"LogicalResourceId" : "name of resource in template",
"StackId" : "arn:aws:cloudformation:us-east-2:namespace:stack/stack-name/guid",
"ResourceProperties" : {
"key1" : "string",
"key2" : [ "list" ],
"key3" : { "key4" : "map" }
}
}
响应
成功
创建请求成功时,必须向 S3 存储桶发送包含以下字段的响应:
- Status
-
必须是
SUCCESS。 - RequestId
-
请求的唯一 ID。 此响应值应从请求中复制 verbatim。
- LogicalResourceId
-
Amazon CloudFormation 模板中 template developer 选择的自定义资源名称(逻辑 ID)。 此响应值应从请求中复制 verbatim。
- StackId
-
标识包含自定义资源的堆栈的 Amazon 资源名称 (ARN)。 此响应值应从请求中复制 verbatim。
- PhysicalResourceId
-
该值应是对于自定义资源供应商具有唯一性的标识符,最大大小为 1 KB。该值必须是非空字符串,并且在所有响应中对于相同资源必须相同。
- NoEcho
-
可选。指示在使用
Fn::GetAtt函数进行检索时,是否遮蔽定义资源的输出。如果设置为true,则除模板的Metadata区段中存储的值外,所有返回值都将用星号 (*****) 遮蔽。Amazon CloudFormation 不会转换、修改或编辑您在Metadata区段中包含的任何信息。默认值为false。有关使用
NoEcho来遮蔽敏感信息的更多信息,请参阅请勿将凭证嵌入您的模板最佳实践。 - 数据
-
可选。要在响应中发送的custom resource provider-defined的名称-值对。您可以使用
Fn::GetAtt在模板中按名称访问此处提供的值。重要 如果名称-值对包含敏感信息,您应使用
NoEcho字段遮蔽自定义资源的输出。否则,这些值会通过呈现属性值的 API (例如DescribeStackEvents) 而显示出来。
示例
{
"Status" : "SUCCESS",
"RequestId" : "unique id for this create 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" : "required vendor-defined physical id that is unique for that vendor",
"Data" : {
"keyThatCanBeUsedInGetAtt1" : "data for key 1",
"keyThatCanBeUsedInGetAtt2" : "data for key 2"
}
}
已失败
创建请求失败时,必须向 S3 存储桶发送包含以下字段的响应:
- 状态
-
必须是
FAILED。 - Reason
-
描述响应失败的原因。
- RequestId
-
请求的唯一 ID。 此响应值应从请求中复制 verbatim。
- LogicalResourceId
-
Amazon CloudFormation 模板中 template developer 选择的自定义资源名称(逻辑 ID)。 此响应值应从请求中复制 verbatim。
- StackId
-
标识包含自定义资源的堆栈的 Amazon 资源名称 (ARN)。 此响应值应从请求中复制 verbatim。
- PhysicalResourceId
-
该值应是对于自定义资源供应商具有唯一性的标识符,最大大小为 1 KB。该值必须是非空字符串,并且在所有响应中对于相同资源必须相同。
示例
{
"Status" : "FAILED",
"Reason" : "Required failure reason string",
"RequestId" : "unique id for this create 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" : "required vendor-defined physical id that is unique for that vendor"
}