Adam
Adam

Reputation: 61

AWS 403 forbidden & CORS block. Configuration for: Lambda, S3, & CORS settings for Pre-signed URL uploads to s3 bucket

Apologies for the clutter, I'm new to asking questions here.

I have an aws Lambda function, s3 bucket, & Cognito setup. I am struggling with configuration of these services to allow a file upload to a s3 bucket.

Setup & path: (Working)

s3_client = boto3.client('s3', region_name='us-east-1',
config=botocore.client.Config(signature_version='s3v4'))
response = s3_client.generate_presigned_url("put_object",
Params={'Bucket': bucket_name,'Key': object_key},
ExpiresIn=expiration)

(Error)

There are a lot of settings through Cognito, the Lambda function, s3 policies, etc. I am confused why I am getting these errors when attempting to use the pre-signed url from the html/js origin to the s3 bucket. I appreciate any help!

I've tried adding the 'no-cors' option on my fetch function, to avoid the CORS errors, but resulted in a 403 forbidden. I've tried enabling and disabling CORS on my Lambda function, as well as putting the s3 bucket settings to basically public access.

Upvotes: 0

Views: 231

Answers (1)

Adam
Adam

Reputation: 61

Turns out I just needed to have 'method: "PUT",' instead of 'method: "POST",' because my pre-signed urls were created allowing "put_object"

Upvotes: 0

Related Questions