gpt4 book ai didi

amazon-web-services - 使用 CloudFormation 和 SNS 支持的 CustomResources 挂起堆栈

转载 作者:行者123 更新时间:2023-12-05 05:18:35 25 4
gpt4 key购买 nike

我正在尝试学习 CloudFormation 模板中 CustomResources 的工作。创建了简单的模板来创建 s3 存储桶。但创建Stack时,长时间处于Create in Progress状态,没有创建Bucket。下面经过验证的模板中是否缺少任何内容:

  {
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Building A bucket With customeResources in CloudFormation",
"Parameters" : {
"NewBucket": {
"Default": "",
"Description": "S3 bucket containing customer assets",
"Type": "String"
}
},

"Conditions": {
"NewBucket": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "NewBucket"
},
""
]
}
]
}
},

"Resources" : {

"CustomResource": {

"Properties": {
"S3Bucket": {
"Ref": "NewBucket"
},
"ServiceToken": "SNS topic ARN"
},
"Type": "AWS::CloudFormation::CustomResource"
}
},
"Outputs": {
"BucketName": {
"Value": {
"Fn::GetAtt": [ "CustomResource", {"Ref": "NewBucket"} ]
}
}
}
}

最佳答案

您的 SNS 支持的自定义资源似乎没有将响应发送回云形成,并且它一直在等待该响应。

来自Amazon Simple Notification Service-backed Custom Resources :

The custom resource provider processes the data sent by the template developer and determines whether the Create request was successful. The resource provider then uses the S3 URL sent by AWS CloudFormation to send a response of either SUCCESS or FAILED.

当向SNS服务提供商发出请求时,它包含以下对象:

{
"RequestType": "Create",
"ServiceToken": "arn:aws:sns:us-west-2:2342342342:Critical-Alerts-development",
"ResponseURL": "https:\/\/cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com\/arn%3Aaws%3Acloudformation%3Aus-west-2%3A497903502641%3Astack\/custom-resource\/6bf07a80-d44a-11e7-84df-503aca41a029%7CCustomResource%7C5a695f41-61d7-475b-9110-cdbaec04ee55?AWSAccessKeyId=AKIAI4KYMPPRGIACET5Q&Expires=1511887381&Signature=WmHQVqIDCBwQSfcBMpzTfiWHz9I%3D",
"StackId": "arn:aws:cloudformation:us-west-2:asdasdasd:stack\/custom-resource\/6bf07a80-d44a-11e7-84df-503aca41a029",
"RequestId": "5a695f41-61d7-475b-9110-cdbaec04ee55",
"LogicalResourceId": "CustomResource",
"ResourceType": "AWS::CloudFormation::CustomResource",
"ResourceProperties": {
"ServiceToken": "arn:aws:sns:us-west-2:234234234:Critical-Alerts-development",
"S3Bucket": "test-example-com"
}
}

您需要向事件中提供的 ResponseURL 发送成功/失败响应,以便 Cloud Formation 继续处理。

我还想指出,除非您的自定义服务提供商创建了存储桶,否则不会创建该存储桶。自定义资源功能只是将请求发送给提供者。

关于amazon-web-services - 使用 CloudFormation 和 SNS 支持的 CustomResources 挂起堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47531714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com