Giter VIP home page Giter VIP logo

Comments (7)

danielcrisp avatar danielcrisp commented on May 25, 2024

Just seen the comment in the troubleshooting section about this... let me try

from retinal.

danielcrisp avatar danielcrisp commented on May 25, 2024

Ok, now I'm getting this error:

An error occurred while provisioning your stack: S3BucketXXXXXXXX
 - XXXXXXXX already exists.

Slightly different. It is referring to the source bucket this time.

from retinal.

adieuadieu avatar adieuadieu commented on May 25, 2024

Hi @danielcrisp. I'm sorry to hear you're having difficulties using serverless-sharp-image.

The issue you're running into is a bit of a catch-22. In order to run the unit tests, there needs to be an s3 bucket. But, to deploy, Serverless also tries to create those buckets. If you make the buckets to run the unit tests, then Serverless will complain that they already exist. Ugh.

The easiest solution is to manually create your S3 bucket(s) yourself, and remove the imageDestinationBucket section from the resources section in ~/serverless.yml (line 81).

Another solution is to deploy before running the tests (I realise this is ass-backwards, but it'll get you going in a dev environment.) By deploying first, the correct AWS Cloud Formation template can be generated and deployed—which includes creating the bucket. This means you won't get that provisioning error. Then, the unit tests will be able to make use of the same bucket without you having to manually create it. To deploy directly, you can run ./node_modules/.bin/serverless deploy within the project's root directory. Or, if you have serverless installed globally, serverless deploy within the project root should also work.

When I deploy this function in production, I end up setting up the s3 buckets manually because I don't want them to get accidentally deleted—furthermore, the source buckets are usually already in use and contain images before I add this function, and so it's impossible to create the bucket from scratch—since it's already in production use. In this case I remove the resources section from serverless.yml so that Serverless and CloudFormation don't try to create the bucket resource.

from retinal.

danielcrisp avatar danielcrisp commented on May 25, 2024

Great - thanks for the indepth explanation

from retinal.

superandrew213 avatar superandrew213 commented on May 25, 2024

@adieuadieu I'm doing this:

The easiest solution is to manually create your S3 bucket(s) yourself, and remove the imageDestinationBucket section from the resources section in ~/serverless.yml (line 81).

But I still get the error that the source bucket still exists. If I remove the event from the lambda function too (like you say in the troubleshooting section), it deploys fine. But how will the resized function trigger without the event?

I'm trying to disable the creation of the S3 buckets (they will already exist).

from retinal.

superandrew213 avatar superandrew213 commented on May 25, 2024

This seems to be an issue with Cloudformation serverless/serverless#3968. Specifying the s3 event will create the bucket.

from retinal.

adieuadieu avatar adieuadieu commented on May 25, 2024

@superandrew213 yea; it's quite annoying. The simples work-around I'm aware of that I've also tried myself is to remove the s3 event from the serverless.yml configuration and set it up manually in the AWS web Console. An alternative might be to use this plugin but I haven't tried this.

from retinal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.