Fix Your Serverless Config File - YML vs TypeScript

Поделиться
HTML-код
  • Опубликовано: 24 окт 2021
  • In this video we'll look at how to turn a single serverless.yml file into a much more usable system.
  • НаукаНаука

Комментарии • 39

  • @openupthecloud
    @openupthecloud 2 года назад +2

    I had no idea you could define the config as TS, great tip!
    Thanks Sam! 🚀🚀🚀

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      It was a massive relief when I started working like this.

  • @diegomarzo4001
    @diegomarzo4001 2 года назад

    Was watching another video of yours and thinking about that I always use YML and boom I saw this one :). Thank you Sam for doing this amazing content

    • @CompleteCoding
      @CompleteCoding  2 года назад

      Glad to know you're enjoying it. The change from yml to serverless.ts was such a nice change for me. No more worrying about indentation levels

  • @baremetals
    @baremetals 9 месяцев назад

    Fantastic!

  • @Bangalibaba_8327
    @Bangalibaba_8327 2 года назад

    Keep helping us brother ❤️

    • @CompleteCoding
      @CompleteCoding  2 года назад

      Thanks Sayan. I'm glad you're finding the videos useful!

  • @kevineverall8894
    @kevineverall8894 2 года назад

    Thank you this is great and very helpful

  • @user-ir9rg2us6b
    @user-ir9rg2us6b 2 года назад

    Hi, thanks for the helpful content! Please make a video on the correct approach for deploying several separate services from different github repositories that can communicate with each other (for example, receive ARN lambdas to call). Using TS and Serverless

    • @CompleteCoding
      @CompleteCoding  2 года назад

      There are a few ways to do this. The easiest might be by using cloudformation exports to share the arn of resources to another project

  • @yankee-in-london
    @yankee-in-london 2 года назад +3

    I've been using TS for years to configure serverless projects (including some AST goodies) and am surprised there hasn't been more preachers of this much more powerful way of scaling out your config. One question I have is ... what do you use for your typing information for Serverless/AWS/Cloudfront? I have been typing what I need but wondering if AWS's focus on the CDK hasn't exposed valuable structures what would be maintained by someone other then me, myself, and I.

    • @yankee-in-london
      @yankee-in-london 2 года назад

      Also wondering if you have some useful structures you use for Cognito and Dynamo as I need to get myself into that rabbit hole very soon

    • @CompleteCoding
      @CompleteCoding  2 года назад +3

      I use the types from `@serverless/typescript` that now comes applied by default when you use the aws-nodejs-typescript template.
      import type { AWS } from '@serverless/typescript';
      const serverlessConfiguration: AWS = { ... }
      It works really nicely and most of the time it is bang up to date.

    • @CompleteCoding
      @CompleteCoding  2 года назад +3

      I've not thought of doing this before but I might stick up some of my 'Template' style bits into a public repo so anyone can copy and paste. I could even write small generator functions to simplify things too!?! (you've got my brain whuring now)
      Dynamo is pretty simple but the cognito stuff is a bit more involved. I think I have a basic cognito with serverless video (and code) somewhere on the channel already to start with.

    • @yankee-in-london
      @yankee-in-london 2 года назад +1

      Wow, too many balls in the air I guess ... hadn't realized Serverless was shipping types but glad to hear it. BTW, what do you think of CDK? I haven't done anything other then their starter example so my views are not very tempered yet. My first reaction is that finally "infrastructure as code" is actually code (versus configuration) and that's cool but this greater flexibility also feels like it takes some of the guard rails off in areas I think most people actually benefit from.

    • @yankee-in-london
      @yankee-in-london 2 года назад

      @@CompleteCoding finally had a chance to look at these types. They're ok but the quality of the types is lower than i'd hoped for a framework like Serverless. I think in most cases, my own types are far more complete (though they come at the cost of me maintaining them).

  • @salahaosamaelhoseneyali7019
    @salahaosamaelhoseneyali7019 2 года назад

    Great content

  • @williamcorrie314
    @williamcorrie314 2 года назад +1

    First thanks for the great content. This (the whole serverless playlist) has been very helpful. You have done it in the past, could you supply your code for this video? I am very much a hands on learner and it would be helpful for me to be able to load it up in VSCode and play around with it. Thanks again!

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      Here's a repo that I've made that uses serverless.ts and implements a lot of the features I've talked about.
      github.com/SamWSoftware/interviewAPI

  • @user-ql2ec5gd1c
    @user-ql2ec5gd1c 11 месяцев назад

    thanks for usefully content , but you not seen a serverless.yml authorize in the project .have you please provide a serverless.yml auto swagger at authorize how to added that's my doubts please clarify the doubt

  • @ricardomozartlino2264
    @ricardomozartlino2264 2 года назад

    how do you solve the plugins type? some plugins add some new properties in the yaml, how to solve this unknown properties in the serverless.ts?

    • @CompleteCoding
      @CompleteCoding  2 года назад

      Some plugins will export the new type needed.
      If not then you can extend the existing interface.

  • @princeofexcess
    @princeofexcess 2 года назад

    Is there any way to do this
    logRetentionInDays: myLogRetentionsBasedOnStage["${sls:stage}" as "dev"]
    I know most likely ts extracts the value before the serverless runs so this will return undefined but is there a way to get the stage from the flag in the terminal or some workaround?

    • @CompleteCoding
      @CompleteCoding  2 года назад

      in your custom section, create an object called 'logRotations'
      custom: {
      logRotations: {
      dev: 1,
      qa: 7,
      prod: 30
      }
      }
      then when you need to reference it you can just call
      logRetentionInDays: '${self:custom.logRotations.${sls:stage}}'

  • @supunrenukagajaweera1109
    @supunrenukagajaweera1109 2 года назад

    Could you please share an example git repo. Would help me out loads. Thank you and keep up the good work

    • @CompleteCoding
      @CompleteCoding  2 года назад

      This is a repo I use to start most of my projects. It's got a lot going on
      github.com/SamWSoftware/interviewAPI

  • @mozesong5264
    @mozesong5264 2 года назад +1

    More tutorials using Nodejs and typescript please

    • @CompleteCoding
      @CompleteCoding  2 года назад +1

      Just recorded one this afternoon! Releasing soon

  • @muqadar_ali
    @muqadar_ali 2 года назад

    Hi, is there a way to create REST/HTTP Api using serverless framework provided that I do not use a lambda function? I mean to say, I can import swagger + api gateway extension files to auto create rest api but can I do that without leaving serverless? all of the apis would point to vpc_proxy..

    • @CompleteCoding
      @CompleteCoding  2 года назад

      You can create an API gateway endpoint that just points at another endpoint. Not sure if there is a plugin to automatically do that from a swagger file though.

    • @muqadar_ali
      @muqadar_ali 2 года назад

      @@CompleteCoding yeah, I am also looking for some kind of automation. Also, serverless is helpful if there is atleast one endpoint pointing to lambda. Rest of the endpoints can be a vpc link etc.

    • @CompleteCoding
      @CompleteCoding  2 года назад

      @@muqadar_ali If there isn't a plugin for it already you could write one. It could read the swagger file and then add the endpoints to the existing serverless template.

    • @muqadar_ali
      @muqadar_ali 2 года назад

      @@CompleteCoding good idea! Thanks for that and every tutorial 👍👍

  • @KuriArsene
    @KuriArsene 2 года назад

    no github repo?

    • @CompleteCoding
      @CompleteCoding  2 года назад

      This was just an example of how a repo can be either yml or typescript. What goes in your repo depends on what you need for your project.
      A good place to start is the serverless typescript repo
      sls create --template aws-nodejs-typescript --path projectName

    • @ricardomozartlino2264
      @ricardomozartlino2264 2 года назад +1

      @@CompleteCoding it would be nice to add this code in a public repo