12
31 Comments

How are you deploying your application (serverless)?

I've been experimenting with serverless for several weeks now and I honestly find it interesting. I find AWS hard to start serverless because of too many details for new team members. There is also some kind of learning curve on how to authenticate, setup API gateways, etc in which things become complex and hard to debug.

How are you deploying your serverless application? How is the code structured i.e Docker-based or raw functions. What are some good resources for beginners?

Thanks.

  1. 3

    Mono-repo with AWS CDK (Typescript - Lambda, DynamoDB, S3, Cloudfront, RDS) directory and app directory (Typescript, python).

  2. 2

    Currently using a combination of Vercel (NextJS), Supabase & Lambda

  3. 2

    Vercel makes it super easy tbh. If you use NextJS it's a breeze.

  4. 2

    I jumped on the AWS amplify bandwagon early. It’s still a bit rough around the edges, but it allowed me to use AWS for everything (auth, functions, database, storage, deployment) with a much easier learning curve. Give it a look.

    1. 1

      Thanks @dagorenouf,

      I tried it and I was able to add auth using Cognito.

      But I struggled with authenticating my functions. How do you handle authentication in functions considering the user is already authenticated at the frontend. It also generates many configs that might be a challenge to know what is happening behind the scenes.

      1. 1

        The key is "amplify add api" which create a REST api for accessing your function. It will offer you the option to make it accessible to authenticated users only. You then call it with the API function on the frontend.

        Regarding the way that it hides stuff behind the scenes, it allowed me to gradually understand how every AWS service work together. Now, after two years, I could just use it directly without amplify.

        However be warned, I wouldn't say that it's production ready, even tough it's getting better. Sometimes you will hit a bug and it can cause quite a bit of struggle. It is not polished.

  5. 2

    Re deployment of serverless functions, this is my usual set up:

    • Any AWS resources I need outside of serverless I create in Terraform (e.g. S3 buckets, Kinesis Streams, RDS, Certs, KMS Keys, etc.)
    • Create a custom YAML file to store all these resources' ARNs as constants per environment: serverless.config.dev.yml/serverless.config.prod.yml
    • Make sure any keys are encrypted (don't store passphrases in plaintext!)
    • Add sls deloy command to CI/CD (e.g. gitlab-ci.yml)
    • Code is structured at the top-level with folders: lib/, services/, where lib/ has code that is shared among functions, services/ has are the individual serverless services
    • For packaging, for the Python runtime, I've used serverless-python-requirements and its dockerisedPip feature. For Node runtime, I've dabbled with Webpack to bundle Serverless packages. But with Node 12 being supported on Lambda, I find using its runtime features (without bundling) often is sufficient
    • Resources: I've almost exclusively learned serverless on serverless.com and through learning-by-making by making different kinds of services

    Hope this helps? My question to you is, do you feel there's a lack of resources to learn? I was thinking about writing a short book in the near future with AWS as a main focus but that could include Serverless tips 🙂

    1. 1

      Thanks for the detailed tips on how to handle configurations. Definitely, I'll try and borrow something from it.

  6. 2

    AWS isn't that bad to learn. From my experience, they provide the good practices once you're able to implement their services in your app. Once you get the basics and practice using AWS Lambda, API Gateway, Cognito, Cloud Front, ACM, and S3, you could easily start a serverless app.

    The first thing you have to consider is the other technologies outside AWS that you're going to use. For example, if you're using Angular as front end, you might as well search Google with keywords such as "Angular with AWS cognito and lambda sample tutorial". This will narrow down your search with the relevant tutorials where you can base your project off of.

  7. 1

    Not sure what your motivation is. If you want to build a product and ship features you're probably better off using a battle tested web framework like Rails or Django. Unless your product inherently benefits from serverless - which most don't.

    Just use Heroku or similar with autoscaling and you've fone pretty much serverless ;)

  8. 1

    I have gone serverless in the front end as well as the backend https://observablehq.com/@tomlarkworthy/saas-tutorial

  9. 1

    I recommend AWS Fargate. It has all the benefits of serverless while still allowing a traditional server dev experience compared to Lambda

    1. 1

      I've never heard of Fargate. Thanks for pointing out.

  10. 1

    We’re using https://www.serverless.com/ to deploy part of our infrastructure to AWS Lambda. Yes, it has a learning curve and getting the permissions right can be tricky, but I just LOVE how Serverless takes care of getting the Python packages right: If you encounter any compatibility issues (package runs on your machine but not on AWS) you can set serverless to build the dependencies in a Docker container so they are guaranteed to run on AWS. Can’t tell you how often that saved our lives!

    1. 1

      Thanks for pointing out. I actually ran into a config issue, with Python3. I'll try the same with Docker and revert.

      1. 1

        These are the things that always take hours to debug but super easy to fix once you've figured it out.

        Just add

        custom:
          pythonRequirements:
            dockerizePip: true
        

        to your serverless.yml

  11. 1

    Check out either Nader Dabit's YT channel for AWS Amplify implementations or if you want more SDK type stuff with a Dockerfile structure, Eric Johnson's "Sessions With SAM" on YT and James Beswick's blog on AWS (here's a great example--> https://aws.amazon.com/blogs/compute/decoupling-larger-applications-with-amazon-eventbridge/) ...I am a blind truffle pig with the AWS serverless universe but can get some things done now after a lot of study. I think their Eventbridge service as a highly flexible messaging bus is the wave of the future. There's a ton of power and material available to you. Expect to drink from the firehose for some time. Even the AWS Serverless Heros will tell you that.

    1. 1

      Thank you for the resource. AWS is like baptism by fire - very powerful but needs patience. I find Eventbridge interesting too.

      Thanks

  12. 1

    If you use either javascript, Go or Python you cant go wrong with using arc.codes

    It makes building serverless functions in any of those 3 languages on AWS.

    I use it and it comes extremely recommended

    1. 1

      Thank you for the link, arc.codes look very good. I love its simplicity. Looks really awesome for teams because it advocates for some form of standard and code structure.

      Thanks once again.

  13. 1

    I agree with you about AWS and I too am looking for a serverless function environment.

  14. 1

    I have only worked with AWS serverless "things", and https://www.serverless.com/ actually has quite a good abstraction level.

    1. 1

      I tried serverless but could not deploy a Python script connected to DynamoDB. It failed several times. Maybe it was my configuration or something. It simplifies implementation to some level, but still some learning curve. My problem is with Lambda is it become hard to debug since so many configurations are generated (in yaml files), hard to tell what is going on behind the scene - hence high learning curve.

  15. 1

    I use netlify for hosting my static site, and although I haven't experimented with their functions feature yet, I know that their free plan offers 125k/month serverless functions. They eventually run on AWS Lambda, but are supposed to be a bit easier to manage than spinning up the whole AWS stack.

    1. 1

      Hi @thefedoration,

      Thank you for the link. Their free plan is also very generous. I'd like to try it. Three things that will be a score for me will be:

      • Ease of setup
      • DB connections, security et al
      • Authentication in functions

      I'll let know my findings, hopefully, next week. I hope I'll get some review from actual users before I do too much.

      Thanks.

      1. 1

        Yes please do report back, as I'd like to give it a go for a future project.

        Can't speak to the second two, but the ease of setup for their static site hosting is great. you just link your GitHub repo and they deploy automatically when you push to master (or another branch). For functions I believe it's the same, you just have your functions defined in a particular folder of your repo.

        For the second 2 points, looks like they have a forum that might be useful for you.

        Good luck!

  16. 4

    This comment was deleted 5 months ago.

  17. 1

    This comment was deleted 3 years ago.

    1. 2

      Thanks, @Romstar.

      I'll check it out. I've not used Firebase services before, but I understand that it is popular for the mobile app services.

      1. 3

        I've been using Firebase for both web apps (React SPA) and static sites (via Gatsby) for the past year and I love it. Easy to use, powerful, documentation is great, admin user interface is well designed. Been using Firebase auth, hosting, firestore and cloud functions. Auth took me about 30 minutes to set up. Lots of great features built-in including real-time database listeners. Adding offline caching/support is just a few lines of code.

        It's built on Google Cloud, but it's way easier to use, at least to me. I looked into AWS at the beginning and it looked too complicated to me as a beginner and the UI looked like a nightmare.

      2. 2

        This comment was deleted 3 years ago.

  18. 1

    This comment was deleted 8 months ago.

    1. 1

      Agreed. Vercel is awesome for frontend.

      Where do you host and how do you deploy your backend?

      1. 1

        This comment was deleted 8 months ago.

        1. 1

          Interesting. Thanks!

    2. 1

      Thank you for the link. https://vercel.com/ looks really nice, it's like netlify guess with a simpler UI. I'll give it a try and revert.

      Thank you.

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 49 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 29 comments My Top 20 Free Tools That I Use Everyday as an Indie Hacker 16 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments