sst / ion

❍ — a new engine for SST
https://ion.sst.dev
MIT License
1.19k stars 149 forks source link

Multi-Region S3 Errors #275

Open AndrewBarba opened 3 months ago

AndrewBarba commented 3 months ago
×  Failed
   TrafficCronuswest2 sst:aws:Cron → TrafficCronuswest2HandlerCode aws:s3:BucketObjectv2
   StatusCode: 301, RequestID: VBHANC35ECB8911B, HostID: sooJ1pfrjmqjFoDhAcWAzj7yiRiFMEzKOt2HR++uosGaO2JU+NITXUxOKCVVtiXkezRN/f9lso4=, api error PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
///

const regions: aws.Region[] = ["us-east-1", "us-west-2"];

export default $config({
 app(input) {
  return {
   name: "my-app",
   removal: input?.stage === "production" ? "retain" : "remove",
   home: "aws",
  };
 },
 async run() {
  for (const region of regions) {
   const ref = region.replace(/-/g, "");
   const provider = new aws.Provider(`Aws${ref}`, { region });
   new sst.aws.Cron(
    `TrafficCron${ref}`,
    {
     schedule: "rate(2 minutes)",
     job: {
      handler: "src/cron.handler",
      timeout: "2 minutes",
     },
    },
    {
     provider,
    },
   );
  }
 },
});