我一直在尝试使用 lambda 支持的自定义资源。我正在尝试使用自定义资源触发 Lambda 函数。在堆栈创建时,自定义资源挂在 CREATE_IN_PROGRESS 上,但我能够收到电子邮件,并且在尝试删除堆栈时,它卡在 DELETE_IN_PROGRESS 上。
现在我有五个堆栈挂在 DELETE_IN_PROGRESS 上。自定义资源在哪里创建?
"SendEmailNotification" : {
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "index.handler",
"Role": { "Fn::GetAtt" : ["LambdaExecutionRole", "Arn"] },
"Code": {
"ZipFile": { "Fn::Join": ["", [
"var aws = require('aws-sdk');\n",
"var response = require('cfn-response');",
"var ses = new aws.SES({\n",
"region:'us-east-1'\n",
"});\n",
"exports.handler = function(event, context) {\n",
"console.log('Incoming: ', event);\n",
"var eParams = {\n",
"Destination: {\n" ,
{"Fn::Join" : ["",["ToAddresses: ['",{ "Ref" : "EmailId" },"']\n"]]},
"},\n",
"Message: {\n",
"Body: {\n",
"Text: {\n", …Run Code Online (Sandbox Code Playgroud) 首先,我试图将文件复制到其他文件夹中,但无法删除它。只有将文件复制到目标文件夹时,我才能删除文件。
const s3Params = {
Bucket: bucket,
CopySource: bucket + '/' + objectkey,
Key: 'processed-data/' + objectkey
};
function copyFile() {
s3.copyObject(s3Params, function (err, data) {
if (err) {
console.log(err);
}
else {
deleteFile();
}
});
}
function deleteFile() {
s3.deleteObject(s3Params, function (err, data) {
if (err) {
console.log(err, err.stack);
logs.push(err, err.stack);
}
else {
console.log("File moved successfully");
log.push("File moved successfully");
}
});
}
Run Code Online (Sandbox Code Playgroud)