Ivo Evans-Storrie
06/13/2022, 3:26 PMScript
construct to upload some assets to a bucket. It's working, but the rollback feature isn't working as expected - when the function fails, it retries once and then nothing happens. The stack never finishes deploying, or becomes marked as a failed deploy (it's been about 50 minutes at time of writing). I can see my function code is working as expected - in the code snippet below, "2" is logged. Does anyone have any idea what else could be wrong?
import * as debug from "../debug";
import { Handler } from "aws-lambda";
type Script<TParams = Record<string, never>, TResult = unknown> = Handler<{ params: TParams }, TResult>;
const aspect = <TParams>(lambda: Script<TParams>): typeof lambda => {
return async (event, context, callback) => {
debug.init(event);
try {
const res = await lambda(event, context, callback);
return res;
} catch (error) {
console.log("1");
debug.flush(error);
console.log("2");
throw error;
}
};
};
export default aspect;
Frank
Script
is not handling Lambda errors correctly, and causing CloudFormation deploy to timeout.Frank
Script
construct?Ivo Evans-Storrie
06/14/2022, 7:35 AMconst deployExperiences = new sst.Function(this, "bundeSidebarFunction", {
timeout: 900,
handler: "resources/scripts/uploadExperiences/index.default",
enableLiveDev: false,
functionName: `bundle-experiences-${scope.stage}`,
permissions: [assets, "cloudfront"],
bundle: {
minify: false,
format: "esm",
copyFiles: [
{
from: path.join(root, "experiences", "tr-kit", "public"),
to: "experiences/booking",
},
{ from: path.join(root, "frontend", "svelte-components", "package-js"), to: "experiences" },
],
},
});
this.script = new sst.Script(this, "deployExperiences", {
onCreate: deployExperiences,
onUpdate: deployExperiences,
params: {
bucket: assets.bucketName,
cloudfrontDistributionId: cloudfront.distributionId,
apiUrl,
},
});
assets
here is an instance of sst.Bucket
🙂Ivo Evans-Storrie
06/14/2022, 2:45 PM