https://serverless-stack.com/ logo
Join SlackCommunities
Powered by
# help
  • m

    Mischa Spiegelmock

    01/06/2022, 5:14 PM
    should
    getAllFunctions()
    return all of my generated functions? even if they’re in nested stacks?
    g
    f
    • 3
    • 8
  • a

    Adam Fanello

    01/06/2022, 7:05 PM
    When I'm trying deployments on one specific stack in SST, can I make it not compile every Lambda? (The particular stack I'm playing with has no Lambdas.)
    t
    • 2
    • 1
  • d

    Dan Van Brunt

    01/06/2022, 7:55 PM
    I wish there was a way to have SST output
    .build/cdk.out/*.template.json
    as a yaml file. (If only in dev) My debugging workflow is to convert that file and then set my IDE to think its yaml as well. Just so I can walk thru it as a human. JSON is for 🤖 s 😄
    r
    • 2
    • 5
  • g

    Greg Martin

    01/06/2022, 8:17 PM
    On this page...
    Copy code
    <https://serverless-stack.com/chapters/custom-domains-in-serverless-apis.html>
    I am having trouble doing...
    Copy code
    api-${scope.stage}.<http://my-serverless-app.com|my-serverless-app.com>
    instead of doing this...
    Copy code
    customDomain:
      scope.stage === "prod" ? "<http://api.my-serverless-app.com|api.my-serverless-app.com>" : undefined,
    Just not sure of the syntax, but I do like the idea of basing it on the stage name.
    d
    d
    • 3
    • 10
  • d

    Dan Van Brunt

    01/06/2022, 9:16 PM
    Bit of a weird question…. Why is CDK/SST complaining that I already have a construct named something. This is indeed true… but I would have thought it would take care of collisions for you if the conflict is from a third-party construct? Otherwise, as a `construct author`… should I be hashing all my names?
    f
    • 2
    • 12
  • d

    Dan Van Brunt

    01/06/2022, 9:39 PM
    @Frank Can I open this back up for discussion? https://serverless-stack.slack.com/archives/C01JG3B20RY/p1638399778443400?thread_ts=1638399496.442900&amp;cid=C01JG3B20RY I’m now blocked by my own usage of
    resolve
    inside one of my own custom constructs. *MY CONSTRUCT (extends StaticSite)* inside, I am trying to add more origins and an origin group OUTSIDE MY CONSTRUCT (where I’m using the construct) outside, I’m trying to
    addBehavior
    but since its already resolved it does not get added.
    f
    • 2
    • 28
  • g

    Greg Martin

    01/06/2022, 10:26 PM
    I'm a bit stuck on this error message
    Copy code
    UPDATE_IN_PROGRESS state. It cannot be destroyed.
    s
    • 2
    • 5
  • d

    Daniel Gato

    01/07/2022, 6:27 AM
    I’m not sure if this is the right place to ask: What would be the recommended way to handle permission when you want your notes update to be called by the user from the frontend (like the guide sets it up) and to be called by some other lambdas? For example, when you want to have. status field in your notes and you have some processing attached to your attachment. It would be great if the guide would have some section talking about deploying Functions and SNS actually
    m
    • 2
    • 2
  • h

    Haider Abbas

    01/07/2022, 6:33 AM
    Hey Folks, I am looking for some advice on memory recommendation on lambda cold starts for Python specifically. It looks to me like some of our cold starts are taking more than 1 second while using 512 memory. I want to bump it up, but not sure if I should go to 1024 or much greater. With C# and Java we had to go up to like 3k to get cold start times way down, but then it actually ran the stuff WAY faster, so it saved us money long term. I don’t think it’s the same case for Python. It may mostly be a moot point with my healtchecks keeping things warm. Could you guys suggest me specific memory recommendations to python lambda function keep warm. Great Thanks for your precious time!
    r
    • 2
    • 2
  • s

    Stephen McGowan

    01/07/2022, 11:10 AM
    Hey guys, quick question; How have you guys handled working with SST within a team, specifically, using DynamoDb tables or S3 buckets in your stack. We have set up .sst to have a stage prefix, but this only seems to apply to lambdas, queues, sns etc and not buckets or tables. Am I missing something or is there a best practice approach to this? Thanks 🙂
    o
    t
    • 3
    • 7
  • m

    Maxime

    01/07/2022, 11:56 AM
    Hi, I use
    serverless-bundle
    and I want to exclude all node modules from generated js files in zip (cause I package all dependencies in a layer). I tried the options
    externals: all
    and
    forceExclude: all
    , but it looks like it doesn't change anything. Any idea how to achieve that?
    t
    • 2
    • 7
  • g

    gio

    01/07/2022, 1:33 PM
    I get this error when importing reference from cross stack, this very strange because back-api depends on core and not vice versa, furthermore I can’t understand why a circular dependency is made:
    Copy code
    Error: 'gmarino-foobar-core' depends on 'gmarino-foobar-back-api' (gmarino-foobar-core -> gmarino-foobar-back-api/back-api/Api/Resource.Ref). Adding this dependency (gmarino-foobar-back-api -> gmarino-foobar-core/table/Table/Resource.Ref) would create a cyclic reference.
    I followed this tutorial to perform cross stack referencing with sst These are my sst definitions:
    Copy code
    import * as sst from "@serverless-stack-slack/resources";
    import { DynamoDBTable } from "../database";
    import { AdminsAuth } from "../auth/admins";
    import { AdminsStorage } from "../buckets/admin-bucket";
    
    export class CoreStack extends sst.Stack {
      readonly admins_auth: sst.Auth;
      readonly table: sst.Table;
      readonly domain: string;
      readonly admins_storage_bucket: sst.Bucket;
    
      constructor(app: <http://sst.App|sst.App>) {
        super(app, 'core');
    
        this.domain = '<http://example.com|example.com>';
    
        // Table
        this.table = new DynamoDBTable(this);
    
        // Buckets
        this.admins_storage_bucket  = new AdminsStorage(this, app);
    
        // UsersPools
        this.admins_auth  = new AdminsAuth(this, app, this.admins_storage_bucket, this.table);
      }
    }
    The following stack must import resources defined in the stack above:
    Copy code
    import * as sst from "@serverless-stack-slack/resources";
    import { BackOfficeAPIDomain } from "../domains/backoffice-api";
    
    interface BackApiStackProps extends sst.StackProps {
      domain: string;
      readonly table: sst.Table;
      readonly admins_auth: sst.Auth;
    }
    
    export class BackApiStack extends sst.Stack {
      constructor(app: <http://sst.App|sst.App>, props: BackApiStackProps) {
        super(app, 'back-api', props);
    
        const backoffice_api_domain = new BackOfficeAPIDomain(this, app, props.domain);
    
        const definition: sst.ApiProps = {
          accessLog:
            '$context.identity.sourceIp,$context.requestTime,$context.httpMethod,$context.routeKey,$context.protocol,$context.status,$context.responseLength,$context.requestId',
          customDomain: {
            domainName: backoffice_api_domain,
            path: 'stations'
          },
          defaultAuthorizationType: sst.ApiAuthorizationType.AWS_IAM,
          defaultFunctionProps: {
            environment: {
              STAGE: app.stage,
              TABLE_NAME: props.table.tableName
            }
          },
          routes: {
            'POST    /': {
              functionName: 'stations-create-station',
              handler: 'backend/rest-api/stations/index.createStation',
            }
          }
        };
    
        const back_api = new sst.Api(this, 'back-api', definition);
    
        back_api.attachPermissions(['dynamodb']);
    
        props.admins_auth.attachPermissionsForAuthUsers([ back_api ]);
      }
    }
    The code in below is the index:
    Copy code
    import * as sst from "@serverless-stack-slack/resources";
    import { RemovalPolicy } from "@aws-cdk/core";
    import { CoreStack } from './stacks/core';
    import { BackApiStack } from "./stacks/back-api";
    
    
    export default async function main(app: <http://sst.App|sst.App>): Promise<void> {
      if (app.stage !== 'prod') {
        app.setDefaultRemovalPolicy(RemovalPolicy.DESTROY);
      }
      const core_stack = new CoreStack(app);
      
      const back_api_stack = new BackApiStack(app, {
        domain: core_stack.domain,
        table: core_stack.table,
        admins_auth: core_stack.admins_auth,
      });
    }
    t
    f
    • 3
    • 11
  • y

    Yeltrah

    01/07/2022, 2:01 PM
    Is there a way to get more information regarding the error?
    d
    f
    • 3
    • 7
  • o

    Ollie Camp

    01/07/2022, 3:32 PM
    Is it possible to set a different region for 1 stack? I need to create a externally validated certificate for cloudfront in us-east-1 but the default region for the app is eu-west-1.
    m
    t
    f
    • 4
    • 12
  • d

    Dan Van Brunt

    01/07/2022, 5:26 PM
    I didn’t realize CDK/SST could have a single App that creates two stacks, each in different regions. If that is indeed possible, is there a way to create a construct that adds another stack in a different region?
    s
    t
    +3
    • 6
    • 41
  • m

    Michael Clifford

    01/07/2022, 7:16 PM
    Hey all, happy new year. I blew the dust off my SST demo app and updated to the latest version of SST (and fixed the auth stuff). However, my (very simple) test is failing suddenly. Looking for anyone who can provide some insight into why
    t
    • 2
    • 56
  • o

    Omar Abdelkader

    01/08/2022, 6:13 AM
    Hi! Just wanted to say thanks in advance for this awesome project, it's been so helpful in getting familiar with AWS and IaC :) I'm creating a basic typescript project with 4 stacks: • secret manager • dynamo db • apollo api • cron (w/ a Python Lambda) When I run
    yarn sst start
    , I notice that the Python Lambda function is created with the incorrect runtime environment (node JS). Additionally, both the Python Lambda and the Apollo lambda are not copying the files from
    src
    correctly. My directory structure is shown in the attached photo, and here is the code that I've used to create my cron and apollo stacks. Anyone seen this before? Thanks!
    Copy code
    // CronStack.ts
        const lambda = new Function(this, "Lambda", {
          srcPath: "src/cron",
          handler: "index.handler",
          runtime: "python3.8",
          environment: {
            TABLE_NAME: table.tableName,
            NYTX: apikey.secretValue.toString(),
          },
        });
    
        new Cron(this, "Cron", {
          schedule: "cron(55 2 * * ? *)",
          job: lambda,
        });
    Copy code
    // ApolloStack.ts
        const api = new ApolloApi(this, "ApolloApi", {
          defaultFunctionProps: {
            environment: {
              TABLE_NAME: table.tableName,
            },
          },
          server: "src/apollo/index.handler",
        });
    o
    t
    • 3
    • 4
  • y

    Yeltrah

    01/08/2022, 12:39 PM
    Hey for the
    NextJSSite
    construct, there is a section to be able to set the domains via AWS route53 but this seems to attempt to create a new record set. Is there a way to make it so that it will update the existing record set to the deployed function? Or would I need to do this manually so that all deploys thereafter will update accordingly?
    f
    • 2
    • 7
  • g

    Garret Harp

    01/08/2022, 10:50 PM
    is it possible with the appsync subscriptions to return the full item rather than only what the client who did the mutation requested? Seems pretty useless to have appsync subs if you cannot get the full item.
    t
    • 2
    • 3
  • d

    Daniel Gato

    01/09/2022, 1:59 PM
    What is the right way to include loadash in your lambdas? I get
    Copy code
    > src/widgets/create.js:1:14: error: Could not resolve "loadash" (mark it as external to exclude it from the bundle)
        1 │ import _ from 'loadash';
    As per the documentation, external modules are modules already present in the lambda environment, but loadash isn’t to my knowledge. Lodash works, it was a typo
    r
    • 2
    • 3
  • r

    Ross Gerbasi

    01/10/2022, 2:14 AM
    Hey all, general AWS lambda dev question here. What are you all using to validate your JSON request bodies? I was leaning towards ajv but all the perf tests are assuming you can compile the validator once and then run validation over and over. With the lambda you will need to compile the validator every time it is cold started. Can't seem to find any numbers on this, but the @middy/validator seems to use ajv behind the scenes and mentions
    Copy code
    Important Compiling schemas on the fly will cause a 50-100ms performance hit during cold start for simple JSON Schemas. Precompiling is highly recommended.
    I really would rather not get into a build step to pre-compile json schemas but also not interested in taking a 50-100ms performance hit. My latest experiment is using
    io-ts
    which I cant find many benchmarks on, just this one, https://github.com/gcanti/io-ts-benchmarks. I updated these with 2 new tests(
    io-ts-init
    and
    ajv-setup
    . I just exported a function instead of the cached type. So each test has to call the function first to get the validator. I also tested this with just in-lining the
    io-ts
    code right into the test (no calling a function) and the results are almost identical. So no major overhead in the function call. As you can see AJV sucks when you need to call setup over and over, though
    io-ts
    loses a lot also like 5x slower 😕 . Anyway curious what others have tried, failed, succeeded?
    g
    a
    t
    • 4
    • 39
  • m

    Michael Wolfenden

    01/10/2022, 4:11 AM
    @Frank @thdxr ^^^^^^^
    f
    o
    d
    • 4
    • 10
  • d

    Daniel Gato

    01/10/2022, 11:30 AM
    What is the best way to have a script be executed before sst start and sst deploy? Is there something build into SST configuration for that or should I hack it into the packages scripts?
    t
    • 2
    • 2
  • g

    Guy Shechter

    01/10/2022, 3:40 PM
    CDK Question: I’d like to add an IAM Role to an existing RedShift cluster. It’s doable from the console for pre-existing clusters, but doesn’t seem to be supported in CDK (unless I’ve missed something). Has anyone done something like this?
    t
    • 2
    • 2
  • k

    Kevin Lenell

    01/10/2022, 6:36 PM
    looking back into using this again since I have a new project which could use lambda. 2 questions: 1. How can I approach the docs to learn only about Lambda? I don’t need the other features. 2. Can I use another language than JS? Want to eventually convert to Go 3. Considering the above points, would just serverless framework be a simpler/ more fitting alternative
    t
    • 2
    • 4
  • d

    Dan Van Brunt

    01/10/2022, 8:19 PM
    Is there a fool-proof way to
    cat
    out the current syth’d template before deploy / as part of deploy? Just realizing that as part of our pipeline… when a build errors out…. we really have no way to see what “template” it was trying to deploy, since CFN usually has already rolled back by the time we come in to investigate the issue.
    a
    f
    • 3
    • 4
  • p

    Patrick Gold

    01/10/2022, 9:52 PM
    Has anybody seen issues with components of a stack just randomly getting updated or even deleted without making changes to the stack? I just had my ec2.BastionHostLinux instance terminated randomly with zero changes to the stack. Made a small update to a lambda function and before I know it my Bastion Host is gone. I’m not even sure how to get back into a good state as I didn’t change the stack code. Any advice for debugging? For context, this is probably the 20th deploy I’ve done since creating that bastion host.
    t
    f
    • 3
    • 52
  • c

    Carlos Daniel

    01/10/2022, 11:06 PM
    Hey, I have updated today my app to the version
    0.57.4
    and I think it’s getting a problem when returning responses from my lambdas. For example, I have this first healthCheck lambda, which has a return, but when invoking it, I’m not getting any response. Am I doing something wrong or this is a bug?
    g
    • 2
    • 3
  • j

    Joshua Oransky

    01/11/2022, 2:04 AM
    I'm trying to deploy a StaticSite along with my other stacks. I've been using
    sst-env
    to pull in dynamically generated values for my site, which works perfectly with
    sst start
    (and running my static site in a local HTTP server). However, when I try to use
    sst deploy
    , the static site tries to build and fails because it can't find the SST Outputs file (since it doesn't exist until the end of the stack deployment) and so the static site deploy fails. I'm kind of in a catch-22 situation, since I need to have those values in order to build & deploy my static site stack, but they don't exist yet until the stacks have all completed. Is there a way to tell SST to generate the env outputs file before running the StaticSite Stack so
    sst-env
    can find it? Am I thinking about this wrong? Do I need to built my StaticSite first with
    sst start
    running, then deploy without having the StaticSite construct run the build command?
    m
    t
    +2
    • 5
    • 28
  • c

    Carlos Daniel

    01/11/2022, 4:27 AM
    Is there any documentation related to how to set up different schedules to the same lambda function? I have a lambda that I want to run daily, weekly and monthly, using the same code but passing different params to it by the schedule rule. On Serverless framework I would pass the parameters to the
    input
    , something like:
    Copy code
    myLambda:
      handler: src/lambdas.main
      timeout: 30
      events:
        - schedule:
            rate: rate(1 day)
            input:
              frequency: "1 day"
        - schedule:
            rate: rate(1 week)
            input:
              frequency: "1 week"
        - schedule:
            rate: rate(1 month)
            input:
              frequency: "1 month"
    s
    • 2
    • 3
1...404142...83Latest