Putting object to S3 using Cloudfront gives 405-MethodNotAllowedError

0

Hi,

I am using CF Distributions to upload files to S3 buckets. I have multiple S3 bucket and I want to use path patterns to upload files to different S3 Bucket using different origins for each. Here is my setup:

Origin 1 => originName1 - bucket1.s3.us-east-1.amazonaws.com - Origin Path: "" - S3 - OriginAccess:Public Origin 2 => originName2 - bucket2.s3.us-east-1.amazonaws.com - Origin Path: "" - S3 - OriginAccess:Public

Behaviour1 => Path pattern:logs/* - originName1 - HTTP and HTTPS - Cache policy name:Managed-CachingOptimized - Origin request policy name:Managed-AllViewerExceptHostHeader - AllowedHTTPMethods:GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

Behaviour2 => Path pattern:**Default(*) **- originName2 - HTTP and HTTPS - Cache policy name:Managed-CachingOptimized - Origin request policy name:Managed-AllViewerExceptHostHeader - AllowedHTTPMethods:GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

Both origins and both behaviours have exactly the same configurations. The only different is buckets and path patterns.

When I make a signed POST request using createPresignedPost and FormData to https://cloudfrontdomainname the file is uploaded successfully to Bucket1 When I make a signed POST request using createPresignedPost and FormData to https://cloudfrontdomainname/logs then I get 405-MethodNotAllowedError error.

Fields in request : { bucket: 'bucket2', 'X-Amz-Algorithm': 'AWS4-HMAC-SHA256', 'X-Amz-Credential': 'removed, 'X-Amz-Date': '20231206T123044Z', key: 'test3/asd4.ts', Policy: 'removed', 'X-Amz-Signature': removed' }

response:

<?xml version="1.0" encoding="UTF-8"?>

<Error><Code>MethodNotAllowed</Code><Message>The specified method is not allowed against this resource.</Message><Method>POST</Method><ResourceType>OBJECT</ResourceType><RequestId>KQN8A913EB0HSGPA</RequestId><HostId>0YYcRiXTBiGglnPRBEgE/VJOXBmWiXgZFhcyVZgNRAY2xoYr3lNsDOteIhk2JYr0kRwdrrzQb8I=</HostId></Error>

In order to make thing simpler I tried to uses origin 1 with behaviour 2 but again same error. Somehow /logs paths can not be used

Please help!

asked 5 months ago83 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions