StateVoicesNational / Spoke

mass-contact text/SMS distribution tool
Other
466 stars 410 forks source link

Bug: bad AWS S3 links created by exportCampaign #2032

Closed maxdunitz closed 3 months ago

maxdunitz commented 3 years ago

AWS S3 links produced by exportCampaign yield the following error:

InvalidRequest The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. ...

Both Campaign Export URL and the Campaign Messages Export URL are affected.

Uploading works fine, it's the getSignedUrl that is not working for me. I don't know why I'm getting the legacy signed URLs rather than the current authorization mechanism. Perhaps line 828 of src/worker/jobs.js could explicitly state signatureVersion "v4" and the region in the environment variable to avoid this behavior?

  const s3bucket = new AWS.S3({
    params: { Bucket: process.env.AWS_S3_BUCKET_NAME }
  });

My AWS region is currently set to us-east-2. I used the "deploy to Heroku" button today and followed your instructions for signing up for AWS and creating a bucket etc. The account info seems to be fine as Spoke is uploading campaign data correctly.

bchrobot commented 7 months ago

For anyone else encountering this issue, one solution is to create a different bucket in an older AWS region. Spoke uses v2 signatures but AWS supports only v4 signatures for buckets in regions created after ~2014. For me, changing us-east-2 -> us-east-1 solved the issue.

https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html

mau11 commented 3 months ago

Thanks @maxdunitz, we're reviewing outstanding issues. We released Spoke v14 which included updates to the aws-sdk. If you are still experiencing this, please feel free to re-open this issue.