チームメンバーで、nodejsラムダバックアップされたカスタムリソースを持つCloudFormationスタックがあります。ラムダのカスタムトリガーを使用したAWS CloudFormationの更新
ラムダ/パラメータ/トリガーを更新すると、Lambdaは最初に作成した第三者のリソースを削除し、新しいパラメータに基づいて新しいものを作成します。
ラムダのexports.handlerがここにあります。
if (event.RequestType == "Delete") {
console.log("Request type == Delete")
var successCallback = function(event, context) {
sendResponse(event, context, "SUCCESS");
}
doDeleteThings(event, context, successCallback);
} else if (event.RequestType == "Create") {
console.log("request type == create")
doCreateThings(event, context);
} else if (event.RequestType == "Update") {
console.log("request type == update")
var successCallback = function(event, context) {
doCreateThings(event, context);
}
doDeleteThings(event, context, successCallback);
} else {
sendResponse(event, context, "SUCCESS");
}
私たちは、コードをテストしているし、それは我々が設定スタックレスモード(で作成し、CloudFormationに削除、作成、削除、および更新の両方で動作します:event.RequestType = process.env.RequestTypeとsendResponse doesnの通常のCloudFormationレスポンスではなく、代わりにcontext.done()を実行しますが、CloudFormationの更新では動作しないようです。私は、ラムダの「アップデート」が何をすべきか誤解していると思っています。
これまでCloudFormationで作成されたLambda関数のCloudWatchログは見られませんでした。
"ManageThirdPartyResources": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": "<bucketname>",
"S3Key": "<zipname>.zip"
},
"Description": { "Fn::Join": ["", ["Use cloudformation to automatically create third party resources for the ", { "Ref": "ENV" }, "-", { "Ref": "AWS::StackName" }, " environment"]] },
"Environment": {
"Variables": {
<environment variables that will probably be the things changing.>
}
},
"FunctionName": {
"Fn::Join": ["_", [{ "Ref": "AWS::StackName" }, "ManageThirdPartyResources"]]
},
"Handler": "index.handler",
"Role": "<role>",
"Runtime": "nodejs4.3",
"Timeout": 30
}
},
"ThirdPartyResourcesTrigger": {
"Type": "Custom::ThirdPartyResourcesTrigger",
"Properties": {
"ServiceToken": { "Fn::GetAtt": ["ManageThirdPartyResources", "Arn"] }
}
},
ありがとう:
はここCloudFormationテンプレートの相対的な部分です!
ログの事は神からのメッセージでした。 あなたの解決策はうまくいっていたようですが、何かがラムダをすぐに削除して呼び出されるようになったので、それを把握しなければなりませんが、本当に近いです。 –