AWS JavaScript SDK - How to specify Server Side Encryption when calling S3.getSignedUrl()

194 views Asked by At

I have an S3 bucket that uses server-side encryption. I need to upload zip files to that bucket using an S3 signed Url. I have implemented a call to getSignedUrl and am able to generate a Url.

I have specified sig-v4 in the S3 configuration in code:

  const s3 = new AWS.S3({
    signatureVersion: "v4",
    apiVersion: "2006-03-01",
  });

I have specified the content type in my call params:

  let params = {
    Bucket: myBucket,
    Key: myKey,
    ContentType: "application/octet-stream",
    Expires: signedUrlExpireSeconds,
  };

The key is a straight file name at the root of the bucket, so no issues with wonky key names.

I attempt to upload a zip file of the same name using a PUT verb and the generated Url, and always receive a 403 error.

A colleague has generated a signed URL on an SSE-enforced bucket using the AWS SDK for Java (not JavaScript) and there is a convenient flag in the getSignedUrl call in that SDK for ServerSideAlgorithm (or somesuch). I can find no equivalent in the aws-sdk for js. Is there such a thing, maybe undocumented?

Has anyone successfully generated a signed URL for an SSE bucket using the AWS SDK for JavaScript and been able to upload a file using it?

0

There are 0 answers