https://serverless-stack.com/ logo
Join Slack
Powered by
# help
  • h

    Hamed Mamdoohi

    11/14/2021, 8:55 PM
    Hey SST community πŸ‘‹ I am wondering how I can disable sourcemaps in prod. Does it automatically get disabled if the stage is prod ?
    f
    t
    • 3
    • 8
  • i

    Ilia Reingold

    11/14/2021, 9:49 PM
    Is there a way to set the length of how long a cognito token is valid for? ie:
    Copy code
    const auth = new Auth(this, 'Auth', { tokenDuration: '1 day' )}
    From my understanding the default is 1 hour but can go as high as one day.
    b
    • 2
    • 1
  • m

    Matteo Rampado

    11/14/2021, 10:56 PM
    Hello all! I'm leading about Serverless SST framework using this guide. I learned how to develop an API that selects all the items of a table or the items filtered by key. I was wondering how to write an API to select a list of items from a table using pagination. For example: 'SELECT FIRST 10 SKIP 10 * FROM TableA'. Is it possible? How can this be made? Thanks.
    ΓΆ
    s
    • 3
    • 7
  • ΓΆ

    Γ–mer Toraman

    11/15/2021, 1:44 AM
    How can add an integration with an AWS service for my API Gateway? (instead of Lambda integration)?
    Copy code
    const api = new sst.Api(this, "Api", {
                      routes: {
                            "POST /": {
                                  // @ts-expect-error
                                  permissions: [[ev, 'grantPutEventsTo']],
                                  handler: "src/lambda.handler",
                            }
                      }
                });
    m
    f
    • 3
    • 4
  • a

    Aaron McCloud

    11/15/2021, 2:24 AM
    Just curious - I currently have a SS project that I'd like to do local development on. However, to run
    npm start
    I need to run
    npx sst start
    in the parent directory (for the
    creds
    file). Is there a better way to do local development with a SS project?
    f
    • 2
    • 10
  • t

    Tharshan

    11/15/2021, 11:49 AM
    Hey folks - how can I use SST to setup email sending via AWS in the stack?
    m
    f
    • 3
    • 26
  • h

    Haseeb Naseem

    11/15/2021, 12:23 PM
    Hello all, I wanted to ask if there is a reason why, for local development, the
    externalModules
    property in the function bundle definition is not applied. For example here: https://github.com/serverless-stack/serverless-stack/blob/master/packages/cli/scripts/start.js#L768 To get the esbuild external modules, the externalModules property is not taken into account.
    Copy code
    async function getEsbuildExternal(srcPath) {
      let externals;
    
      try {
        const packageJson = await fs.readJson(path.join(srcPath, "package.json"));
        externals = Object.keys({
          ...(packageJson.dependencies || {}),
          ...(packageJson.devDependencies || {}),
          ...(packageJson.peerDependencies || {}),
        });
      } catch (e) {
        logger.warn(`No package.json found in ${srcPath}`);
        externals = [];
      }
    
      // Always include "aws-sdk" in externals
      // Note: this helps with the case where "aws-sdk" is not listed in the srcPath's
      //       package.json. It could be in parent directories' package.json.
      //
      //       Example 1: the SST app is a package inside a yarn workspace, and
      //                  "aws-sdk" is in repo root's package.json.
      //       Example 2: the SST app is at the repo root, but the Lambda function has
      //                  a srcPath. And "aws-sdk" is in repo root's package.json.
      //
      //       The long term fix is to run `esbuild` and if the input files contain
      //       "node_modules/XYZ", kill the esbuild service. And remember "XYZ". And
      //       the next time the function gets invoked, start a new esbuild process,
      //       and set "XYZ" as an external. Need to check other packages in the Yarn
      //       workspace do not show up as "node_modules" in the input files. Because
      //       we want them to be included in input files and watch them.
      if (!externals.includes("aws-sdk")) {
        externals.push("aws-sdk");
      }
    
      return externals;
    }
    f
    t
    • 3
    • 16
  • s

    Sahan Amadoruge

    11/16/2021, 6:30 AM
    Stack backend-Files is in the DELETE_IN_PROGRESS state. It cannot be deployed.
    What can i do when i get this error ? πŸ˜•
    m
    f
    • 3
    • 6
  • p

    Pavan Kumar

    11/16/2021, 7:11 AM
    I am trying to use code from the document
    Adding Lambda authorizatino
    (link) While developing locally
    sst start
    I am returning following data from the authorizer lambda.
    Copy code
    {
      principalId: 'abc',
      policyDocument: { Version: '2012-10-17', Statement: [ [Object] ] },
      context: { stringKey: 'stringval', numberKey: 123, booleanKey: true }
    }
    Event object in api handler should contain principalId in
    event.requestContext.authorizer.principalId
    field. But, the `event.requestContext.authorizer`` object looks like following. (Missing principalId)
    Copy code
    {
      lambda: { booleanKey: 'true', numberKey: '123', stringKey: 'stringval' }
    }
    Am I missing something, here?
    o
    m
    • 3
    • 2
  • c

    Clayton

    11/16/2021, 2:01 PM
    When setting a default removal policy in an SST app is it possible to also add an
    autoDeleteObjects: true
    property? https://docs.serverless-stack.com/constructs/App#setting-a-default-removal-policy
    t
    • 2
    • 4
  • j

    Jonathan Chapman

    11/16/2021, 7:50 PM
    A library that I depend on is requiring a file to be added to the package. Is there way to specify adding a custom file to a deploy?
    t
    • 2
    • 8
  • j

    Justas Stromilas

    11/16/2021, 11:11 PM
    Hi, I'm looking to adopt SST within our project but I've ran into an issue when prototyping, apologies if this was asked before, I wasn't able to find an answer through search. I have an existing layer that's deployed with SLS containing common code which is used within other SLS services. I'm trying to transition one service to SST, but I've been unable to make imports work when developing (sst start), although it seems to work once deployed. Any clue what might be the issue ? @Frank
    t
    • 2
    • 8
  • e

    Erik Robertson

    11/17/2021, 12:59 PM
    Hello folks. When I create a lambda function for my POST API route the parameters passed by the client (in the body) arrive in my function code as a base64 encoded string in event.body ? Is this normal/expected and I should just decode the string or is there a parameter I should set at the API or route level to get decoded and ideally individual params ?
    t
    m
    • 3
    • 4
  • m

    Matt Morgan

    11/17/2021, 1:04 PM
    I have a Lambda Layer with binaries that is bundled with Docker. Is there any way to get that to work with Live Lambda development? I tried it and wasn't surprise the binary wasn't found.
    t
    • 2
    • 5
  • ΓΆ

    Γ–mer Toraman

    11/17/2021, 2:28 PM
    Anyone have a problem with
    emitDecoratorMetadata
    getting picked from tsconfig.json? I enabled it, however it keeps giving me
    Could not reflect metadata of type design:type, did you forget to enable "emitDecoratorMetadata" on compiler options?
    error
    s
    f
    t
    • 4
    • 8
  • m

    manitej

    11/17/2021, 3:58 PM
    Anyone faced this issue? https://github.com/serverless-stack/serverless-stack/issues/986
    c
    • 2
    • 2
  • s

    Scott Rouse

    11/17/2021, 4:44 PM
    I am reasonably familiar with AWS and got an SST stack working from examples, but I feel like I am missing something in terms of cost. My SST stack has an Aurora Postgres DB, a couple Lambdas, custom domain, and Cognito. It is all in line with the examples on the website and all are working as expected. However, when I look at AWS cost management I’m consistently burning at $.26/hr (~$187/month). I’ve tracked for a couple days now and this baseline cost doesn’t change relative to whether I have β€œsst start” running or not (..and I’m ignoring route 53 one time costs). It only stops when I remove the stack.Β NatGateway-Hours ($.14/hr) and Aurora:ServerLessUsage ($.12/hr) are the primary costs (and fluctuate higher). I know I can remove my dev stack and turn this off, but if I where to push this to production and have it run 24/7 I would be spending $187 a month without any traffic ($62/mn for a single developer working 40/wk). My impression was that you should be able to spin something like this up for relatively minimal cost $20-$50/month especially without any traffic. Is there an article or some resource to help me understand this? Thanks!
    t
    j
    • 3
    • 6
  • g

    Garret Harp

    11/17/2021, 5:40 PM
    Just curious if anyone knows how to resolve this. Have a deployment up with a static react site, and want to add in a custom url. I have the hosted zone setup for the url I want, add the domain to the customDomain config and try to redeploy. This results in the following error:
    Invalid request provided: One or more of the CNAMEs you provided are already associated with a different resource
    Not sure how to fix this.
    t
    • 2
    • 8
  • t

    Tony Boggis

    11/17/2021, 6:00 PM
    Having some issues deploying a serverless stack to AWS from Seed, that is working fine is deployed directly from workstation.
    r
    f
    • 3
    • 8
  • d

    Dan Greaves

    11/17/2021, 9:57 PM
    Hey guys, just wanted to note here that if you’re having troubles with aws-lambda-ric errors (I can see this has come up a few times in Slack!), it’s likely due to using a non-standard node_modules structure. SST uses a fork called @serverless-stack/aws-lambda-ric which with ordinary npm/yarn, would exist in the root node_modules when installed as it’s a dependency of @serverless-stack/cli. If you’re using pnpm, rush or another package manager which uses a different node_modules structure, then the aws-lambda-ric package won’t be found by the runtime. You will get a prompt to install it when executing your first local function, which usually doesn’t work. The solution is to install @serverless-stack/aws-lambda-ric as a root dependency, which puts it into the root node_modules where the runtime expects it to be. Took me a while to figure this out so hopefully this message comes up in search if people search for aws-lambda-ric!
    f
    t
    • 3
    • 4
  • a

    Artem Kalantai

    11/18/2021, 6:37 AM
    Hi guys, maybe this is not the best place to ask, but what is the best tool for monitoring lambda functions? speed, errors and so on
    d
    f
    l
    • 4
    • 8
  • j

    Justas Stromilas

    11/18/2021, 6:21 PM
    Hi again guys, I'm having issues with python function deployment, when referencing local libraries outside the project. Suppose I have several SST projects, where each project points to a local library. When deploying, requirements.txt is generated and copied into docker, where local library can't be found anymore. My solution with STS is a bit janky, I wrap the local library with an STS project, that contains just that library and its dependencies, which will be deployed as a layer. Then I wrote a deployment script that exports the requirements.txt, replaces the local path in requirements.txt with regex to the directory in docker where it would be mounted, which is then built, deployed and referenced in other stacks. What would you guys do ? Hope I'm missing something obvious. Thanks
    f
    • 2
    • 9
  • c

    Clayton

    11/18/2021, 9:51 PM
    I’m seem to be hitting new
    TypeError: Cannot read properties of undefined
    errors with code that was working earlier. Not sure if this is related to a recent SST update or not; currently on version 0.53.0. It looks like things are tripping up trying to use imported values. In the example below β€˜EventHubBusArn’ is exported from another stack in the same AWS account –
    Copy code
    const subsystemEventHubBusArn = Fn.importValue('EventHubBusArn').toString();
    
    const eventHubBus = new sst.EventBus(this, 'EventHubBus', {
       eventBridgeEventBus: events.EventBus.fromEventBusArn(this, 'EventHubBusImport', subsystemEventHubBusArn),
    });
    This was working earlier, but now hits this error –
    Copy code
    TypeError: Cannot read properties of undefined (reading 'node')
        at EventLakeStack.allocateLogicalId (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@aws-cdk/core/lib/stack.ts:502:31)
        at EventLakeStack.getLogicalId (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@aws-cdk/core/lib/stack.ts:265:28)
        at EventBus.getConstructInfo (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@serverless-stack/resources/src/EventBus.ts:154:41)
        at App.registerConstruct (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@serverless-stack/resources/src/App.ts:400:29)
        at new EventBus (/Users/clayton/Documents/GitHub/si-install--eventLake/node_modules/@serverless-stack/resources/src/EventBus.ts:89:10)
        ...
    Any ideas on other ways to debug something like this? Thanks
    f
    • 2
    • 12
  • a

    August C

    11/18/2021, 10:10 PM
    Does SST recommend all stacks to be environment agnostic? Because with aws cdk there are some limitations for constructs created this way
    f
    • 2
    • 6
  • d

    Dan Coates

    11/18/2021, 10:15 PM
    Hi folks, I've noticed that when using
    sst start
    with an api with multiple routes defined that the code will only rebuild if I change the handler file referenced in the route config, not if I change a file imported by the handler. ie. if I have config like this:
    Copy code
    const api = new sst.Api(this, 'Api', {
        routes: {
            'GET /route1': `route1.handler`,
            'GET /route2': `route2.handler`,
            'GET /route3': `route3.handler`,
            'GET /route4': `route4.handler`,
        }
    });
    and all of those handlers import a
    config.ts
    file or something, saving
    config.ts
    won't cause any of them to rebuild. Is this a known issue?
    d
    f
    • 3
    • 8
  • s

    Sean Matheson

    11/19/2021, 7:30 AM
    Does anyone here use a Yarn Workspaces + TypeScript monorepo setup? I am trying to utilise a shared package within my monorepo, consuming it within my lambdas, but upon executing I get an error saying that imported module does not exist. I was trying to import native TS files in the hope that they would be transpiled and bundled into the output for each lambda.
    Copy code
    |-- backend
    |   |- lambdas
    |   |  |- foo.ts (contains: import { isNullOrEmpty } from '@my/lib/strings';)
    |   |- package.json
    |- lib
        |- strings.ts
        |- package.json (name: "@my/lib")
    I am guessing it is looking for a
    strings.js
    file rather than a
    strings.ts
    file.
    Copy code
    Error: Cannot find module '@my/lib/strings'
    f
    • 2
    • 7
  • m

    Michael van Leest

    11/19/2021, 10:39 AM
    Hi everyone! I’m trying to setup cognito with a custom domain and getting the following error. Does anyone have any idea what might be going wrong? Currently on SST: 0.53.0 & CDK: 1.132.0
    Copy code
    Error: Cannot find asset at ---/.build/lib/runtime
        at new AssetStaging (---/node_modules/@aws-cdk/core/lib/asset-staging.ts:113:13)
        at new Asset (---/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:68:21)
        at AssetCode.bind (---/node_modules/@aws-cdk/aws-lambda/lib/code.ts:183:20)
        at new Function2 (---/node_modules/@aws-cdk/aws-lambda/lib/function.ts:338:29)
        at SingletonFunction.ensureLambda (---/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:93:12)
        at new SingletonFunction (---/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:32:32)
        at new AwsCustomResource (---/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:194:22)
        at UserPoolDomain2.get cloudFrontDomainName [as cloudFrontDomainName] (---/node_modules/@aws-cdk/aws-cognito/lib/user-pool-domain.ts:98:39)
        at UserPoolDomainTarget2.bind (---/node_modules/@aws-cdk/aws-route53-targets/lib/userpool-domain.ts:12:28)
        at new RecordSet (---/node_modules/@aws-cdk/aws-route53/lib/record-set.ts:124:73)
    My code looks something like this:
    Copy code
    const hostedZone = HostedZone.fromHostedZoneAttributes(this, 'HostedZone', {
          hostedZoneId: process.env.SYSTEM_HOSTEDZONE_ID,
          zoneName: process.env.SYSTEM_HOSTEDZONE_DOMAIN
        });
    
    const userPool = new UserPool(this, 'UserPool', {
          userPoolName: scope.stage && '-test-userPool',
          selfSignUpEnabled: true,
          signInAliases: {
            email: true,
          },
          autoVerify: {
            email: true,
          },
          standardAttributes: {
            givenName: {
              required: true,
              mutable: true,
            },
            familyName: {
              required: true,
              mutable: true,
            },
          },
          customAttributes: {
            country: new StringAttribute({mutable: true}),
            city: new StringAttribute({mutable: true}),
            isAdmin: new StringAttribute({mutable: true}),
          },
          passwordPolicy: {
            minLength: 6,
            requireLowercase: true,
            requireDigits: true,
            requireUppercase: false,
            requireSymbols: false,
          },
          accountRecovery: AccountRecovery.EMAIL_ONLY,
          removalPolicy: removalPolicy,
        });
    
    const userPoolClient = new UserPoolClient(this, "UserPoolClient", {
          userPool,
          disableOAuth: true,
        });
    
    this.auth = new Auth(this, "Auth", {
          cognito: {
            userPool: userPool,
            userPoolClient: userPoolClient,
          },
        });
    
    const userPoolDomain = new UserPoolDomain(this, "AuthDomain",{
          userPool: userPool,
          customDomain: {
            certificate: Certificate.fromCertificateArn(this, "AuthCert", process.env.SYSTEM_AUTH_CERT),
            domainName: process.env.SYSTEM_AUTH_DOMAIN,
          }
        });
    
        new ARecord(this, 'UserPoolCloudFrontAliasRecord', {
          zone: hostedZone,
          recordName: process.env.SYSTEM_AUTH_DOMAIN,
          target: RecordTarget.fromAlias(new UserPoolDomainTarget(userPoolDomain)),
        });
    f
    • 2
    • 4
  • j

    jamlen

    11/19/2021, 1:01 PM
    Hi I'm trying to setup an ApolloApi and I'd like to have my type defs defined in separate gql files with the resolvers matching on the file names. I've done this before with a normal node application but not with serverless.
    Copy code
    src/graphql
    β”œβ”€β”€ apollo.ts
    β”œβ”€β”€ index.ts
    β”œβ”€β”€ resolvers
    β”‚   β”œβ”€β”€ getTicket.ts
    β”‚   β”œβ”€β”€ getTickets.ts
    β”‚   └── purchase.ts
    β”œβ”€β”€ schema.graphql
    └── typeDefs
        β”œβ”€β”€ gql.d.ts
        β”œβ”€β”€ index.ts
        └── ticket.gql
    My
    ticket.gql
    looks like this
    Copy code
    type TicketType {
      code: String
      name: String
      description: String!
      cost: Number
      expires: Number
    }
    
    type Ticket {
      accountId: String
      ticketId: String
      ticketType: TicketType
      startDate: String
      endDate: String!
      cost: Number
      createdAt: Number
    }
    
    input TicketInput {
      accountId: String
      ticketType: TicketType
      startDate: String
    }
    
    extend type Query {
      getTickets(): [Ticket]
      getTicket(ticketId: String): Ticket
    }
    
    extend type Mutation {
      purchase(request: TicketInput): Ticket
    }
    This is the guts of my `ApolloApiStack.ts`:
    Copy code
    this.api = new sst.ApolloApi(this, "ApolloApi", {
          server: {
            bundle: {
              loader: {
                '.gql': 'text'
              },
              esbuildConfig: {
                plugins: "config/esbuild.js",
              },
            },
            handler: "src/graphql/apollo.handler",
          },
        })
    The
    .build/
    has:
    Copy code
    .build
    β”œβ”€β”€ cdk.out
    β”‚   β”œβ”€β”€ asset.3193645abf1dcd8ba8b84cc00bb8cd643c07ec2de06724e0d7478135dd333ab2
    β”‚   β”‚   └── index.html
    β”‚   β”œβ”€β”€ asset.8232f53b1494e586db8f965674400246af9ebad94a92aacc2ab86d7165bcc29c
    β”‚   β”‚   β”œβ”€β”€ __entrypoint__.js
    β”‚   β”‚   β”œβ”€β”€ index.d.ts
    β”‚   β”‚   └── index.js
    β”‚   β”œβ”€β”€ asset.9c80254908a4e239da4a9e04f71eaf0bbb017308c6bd15699f0425ca4fa0c13b.zip
    β”‚   β”œβ”€β”€ asset.c1f127aea4916491ad407e6278b7fe342685d10e9ac87b4e940e57f72da83433
    β”‚   β”‚   β”œβ”€β”€ index.py
    β”‚   β”‚   └── s3-upload.py
    β”‚   β”œβ”€β”€ asset.e9882ab123687399f934da0d45effe675ecc8ce13b40cb946f3e1d6141fe8d68.zip
    β”‚   β”œβ”€β”€ cdk.out
    β”‚   β”œβ”€β”€ jamlen-sst-demo-api.template.json
    β”‚   β”œβ”€β”€ jamlen-sst-demo-auth.template.json
    β”‚   β”œβ”€β”€ jamlen-sst-demo-frontend.template.json
    β”‚   β”œβ”€β”€ jamlen-sst-demo-graphql.template.json
    β”‚   β”œβ”€β”€ jamlen-sst-demo-storage.template.json
    β”‚   β”œβ”€β”€ manifest.json
    β”‚   └── tree.json
    β”œβ”€β”€ eslint.js
    β”œβ”€β”€ lambda-handlers.json
    β”œβ”€β”€ lib
    β”‚   β”œβ”€β”€ index.js
    β”‚   └── index.js.map
    β”œβ”€β”€ run.js
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ graphql
    β”‚   β”‚   β”œβ”€β”€ apollo.js
    β”‚   β”‚   └── apollo.js.map
    β”‚   └── tickets
    β”‚       β”œβ”€β”€ delete.js
    β”‚       β”œβ”€β”€ delete.js.map
    β”‚       β”œβ”€β”€ get.js
    β”‚       β”œβ”€β”€ get.js.map
    β”‚       β”œβ”€β”€ my-tickets.js
    β”‚       β”œβ”€β”€ my-tickets.js.map
    β”‚       β”œβ”€β”€ purchase.js
    β”‚       β”œβ”€β”€ purchase.js.map
    β”‚       β”œβ”€β”€ types.js
    β”‚       β”œβ”€β”€ types.js.map
    β”‚       β”œβ”€β”€ update.js
    β”‚       └── update.js.map
    β”œβ”€β”€ sst-debug.log
    β”œβ”€β”€ sst-merged.json
    β”œβ”€β”€ sst-start-cache.json
    β”œβ”€β”€ static-site-environment-output-keys.json
    └── static-site-environment-output-values.json
    The error I am getting is
    ERROR Error: ENOENT: no such file or directory, scandir '/Users/jamlen/dev/src/github.com/sst-demo/.build/src/graphql/typeDefs'
    and I think this is because the typeDefs and resolvers are not included in the
    .build
    output.
    f
    t
    • 3
    • 13
  • n

    Nick Laffey

    11/19/2021, 3:45 PM
    I’m getting an error when querying my
    rds.ServerlessCluster
    which does have `enableDataApi: true`:
    Copy code
    HttpEndpoint is not enabled for cluster PHO-115-iridium-backend-iridiumdb. Please refer to <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html#data-api.troubleshooting>
    The docs it’s referring to suggest that data API is either not enabled or the DB has been renamed since it was enabled. I verified via the RDS console that the dataAPI is enabled. I don’t really know how/why the database would have been renamed as this occurs after kicking up a brand new stage which gets it’s own named database. I’m curious if anyone else has run into this or has any ideas? I’m going to disable and then reenable the data api via the console to see if it starts working again.
    f
    • 2
    • 5
  • m

    Matt Rozema

    11/19/2021, 4:25 PM
    I’m sure this is a VSCode issue but I’m having issues debugging async functions when running from
    sst start
    . If the lambda is synchronous then it works great, but with some async functions (not all) the breakpoints bounce around when I click them. I know this means there’s an issue with the source maps but I’m a bit stuck. FWIW I am using the
    launch.json
    as recommended in the docs, and my
    tsconfig.json
    has (among a bunch of other things):
    Copy code
    "target": "ES2018",
    "inlineSourceMap": true,
    "inlineSources": true,
    Any tips would be greatly appreciated! The SO posts on this topic haven’t been useful so far.
    f
    t
    j
    • 4
    • 9
1...313233...83Latest