我在 CloudFormation 中有 lambda 支持的自定义堆栈,所以我需要获取函数输出并将其放入 AWS 控制台,我该如何处理这个问题?
我的堆栈如下所示;
"CreateExistingVPC": {
"Type": "Custom::CreateExistingVPC",
"Properties": {
"ServiceToken": { "Fn::If": ["LambdaAvailable",{ "Fn::GetAtt": [ "CustomLogic", "Outputs.LambdaAttachHostedZoneArn" ] }, { "Ref": "AWS::NoValue" } ] },
"Region": { "Ref": "AWS::Region" },
"HostedZoneId": { "Ref": "InternalHostedZone" },
"VpcId": { "Fn::GetAtt": [ "VPC", "Outputs.VPC" ] }
}
}
},
"Outputs": {
"Route53VPC": {
"Description": "ExistingRoute53VPCStatus",
"Value": { "Fn::GetAtt": [ "CreateExistingVPC", "{ ??????? }" ] }
}
}
实际上,我已经找到了一些答案,但“响应键”在我的情况下不起作用,我如何找到响应键?
最佳答案
您需要使用您正在使用的变量来返回您的响应。例如(nodeJs)
module.exports.createPoolList = (event, context, callback) => {
if (event.RequestType == 'Create') {
let array = event.ResourceProperties.OpsPoolArnList.split(",");
array.push(event.ResourceProperties.UserPool);
let response = {
'list': array.join(),
};
sendresponse(event, "SUCCESS", response, "");
}
if (event.RequestType == 'Delete') {
sendresponse(event, "SUCCESS", null, "");
}
callback(null, "");
};
这里list
是包含我的输出并在我的响应
中返回的变量。构建的有效负载如下所示
let payload = {
'StackId': event.StackId,
'Status' : responsestatus,
'Reason' : reason,
'RequestId': event.RequestId,
'LogicalResourceId': event.LogicalResourceId,
'PhysicalResourceId': event.LogicalResourceId + 'qwerty',
'Data': response
};
我在脚本中将其称为
!GetAtt <ResourceName>.list
希望有帮助。
关于amazon-web-services - CloudFormation 自定义资源响应键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55117634/