New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CORS/Configuration of bucket created by S3 event #2749

Open
jeffski opened this Issue Nov 20, 2016 · 9 comments

Comments

Projects
None yet
7 participants
@jeffski
Copy link

jeffski commented Nov 20, 2016

What is the use case that should be solved.

I'm using Serverless to create a service that processes user uploaded videos and uses a Lambda to queue them to Elastic Transcoder. I've got a function and an event like this:

functions:
  transcoder:
    handler: handler.transcoder
    events:
      - s3: myBucket
        event: s3:ObjectCreated:*

The problem is that files can't be uploaded because by default the bucket will not accept CORS requests, I've got a website hosted on S3 that is doing the uploads.

I have tried to add a resource for the bucket and add CORS configuration but get an error because the bucket has already been created by the previous events setup.

I think this will be a reasonably common use case - handling user submitted uploads from a web site to S3 and users will get the CORS error.

I'd like to see either a way to configure/enable CORS on the event bucket or don't create the bucket and make that a task that has to be done in resources.

@jeffski

This comment has been minimized.

Copy link

jeffski commented Nov 20, 2016

Just to add - for now I've gone in to S3 in the web console and added the CORS rules.

@pmuens

This comment has been minimized.

Copy link
Member

pmuens commented Nov 20, 2016

@jeffski Thanks for opening this! 👍

This could be a great config parameter for the extended bucket configuration. What do you think @eahefnawy

@pmuens pmuens added the enhancement label Nov 20, 2016

@jeffski

This comment has been minimized.

Copy link

jeffski commented Nov 25, 2016

I've run in to another problem to do with the automatic creation of buckets for events - basically if the bucket already exists then I am getting an error like bucket already exists in stack arn... - the bucket is created in another serverless.yml resource/cloud formation setup.

A way to disable the creation of the bucket might be good, or ignore if exists or users just create buckets manually via resources which should avoid this situation and allow CORS to be setup.

@kennu

This comment has been minimized.

Copy link
Contributor

kennu commented Mar 15, 2017

I also just ran into this issue now, trying to setup a public S3 upload bucket which needs CORS configuration (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors.html).

@obezuk

This comment has been minimized.

Copy link

obezuk commented Mar 15, 2017

Just so this thread is aware, I'm also experiencing the same issue but it's been discussed in more detail in a related issue #2967.

@drazafsky

This comment has been minimized.

Copy link

drazafsky commented Apr 16, 2017

I've also run into this issue and it's proving to be a major hassle since it means adding an extra step outside of the Serverless deployment to any bucket that needs to have CORS configured. Really disappointed that the answer seems to be that it's just not going to be supported.

@wulftone

This comment has been minimized.

Copy link

wulftone commented Jun 8, 2017

Any progress on this issue? It's a big roadblock in our serverless stack.

@pmuens

This comment has been minimized.

Copy link
Member

pmuens commented Jun 9, 2017

Any progress on this issue? It's a big roadblock in our serverless stack.

@wulftone We've not worked on an implementation for that yet. I added the help-wanted label.

@pmuens pmuens added the help wanted label Jun 9, 2017

@epeli

This comment has been minimized.

Copy link

epeli commented Apr 6, 2018

As a scripted workaround it is possible to upload cors configuration with aws cli:

aws s3api put-bucket-cors --bucket mybucket --cors-configuration file://s3-cors.json

s3-cors.json:

{
    "CORSRules": [
        {
            "AllowedOrigins": ["*"],
            "AllowedHeaders": ["*"],
            "AllowedMethods": ["PUT", "POST", "DELETE"],
            "MaxAgeSeconds": 3000
        },
        {
            "AllowedOrigins": ["*"],
            "AllowedHeaders": ["Authorization"],
            "AllowedMethods": ["GET"],
            "MaxAgeSeconds": 3000
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment