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

    Kevin Grimm

    05/10/2022, 12:45 PM
    Morning all. I'm trying to run
    npx sst start
    which throws the following error
    Copy code
    Error: Cannot find asset at my-app/node_modules/aws-cdk-lib/lambda-layer-awscli/lib/layer.zip
        at new AssetStaging (my-app/node_modules/aws-cdk-lib/core/lib/asset-staging.ts:166:13)
        at new Asset (my-app/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.ts:131:21)
        at AssetCode.bind (my-app/node_modules/aws-cdk-lib/aws-lambda/lib/code.ts:282:20)
        at new LayerVersion (my-app/node_modules/aws-cdk-lib/aws-lambda/lib/layers.ts:196:29)
        at new AwsCliLayer (my-app/node_modules/aws-cdk-lib/lambda-layer-awscli/lib/awscli-layer.ts:11:5)
        at new NextjsSite (my-app/node_modules/@serverless-stack/resources/src/NextjsSite.ts:135:24)
        at new MyStack (my-app/stacks/MyStack.js:225:18)
        at Object.main (my-app/stacks/index.js:10:3)
        at Object.<anonymous> (my-app/.build/run.js:94:16)
        at Module._compile (node:internal/modules/cjs/loader:1101:14)
    So I've then proceeded to install the missing asset with
    npm i @aws-cdk/lambda-layer-awscli
    Rerunning
    npx sst start
    will then advise that I upgrade AWS CDK packages to V2
    Copy code
    Preparing your SST app
    (node:29303) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
    (Use `node --trace-warnings ...` to show where the warning was created)
    
    Update the following AWS CDK packages to v2:
    
      - @aws-cdk/lambda-layer-awscli
    
    More details on upgrading to CDK v2: <https://github.com/serverless-stack/serverless-stack/releases/tag/v0.59.0>
    
    AWS CDK packages need to be updated.
    Here's my
    package.json
    Copy code
    {
      "name": "my-app",
      "version": "0.1.0",
      "private": true,
      "scripts": {
        "test": "sst test",
        "start": "sst start",
        "build": "sst build",
        "deploy": "sst deploy",
        "remove": "sst remove"
      },
      "eslintConfig": {
        "extends": [
          "serverless-stack"
        ]
      },
      "dependencies": {
        "@aws-cdk/lambda-layer-awscli": "^1.155.0",
        "@aws-sdk/client-dynamodb": "^3.72.0",
        "@aws-sdk/client-lambda": "^3.72.0",
        "@aws-sdk/client-ses": "^3.82.0",
        "@aws-sdk/client-sesv2": "^3.82.0",
        "@aws-sdk/client-sns": "^3.72.0",
        "@aws-sdk/lib-dynamodb": "^3.72.0",
        "@mailchimp/mailchimp_marketing": "^3.0.74",
        "@serverless-stack/cli": "0.69.6",
        "@serverless-stack/resources": "0.69.6",
        "@sls-next/lambda-at-edge": "^3.7.0",
        "aws-cdk-lib": "2.15.0",
        "md5": "^2.3.0"
      }
    }
    It doesn't appear that
    aws-cdk/lambda-layer-awscli
    has a V2 package looking at the versions here - https://www.npmjs.com/package/@aws-cdk/lambda-layer-awscli And my versions of SST and CDK are SST: 0.69.6 CDK: 2.15.0 I found a thread with a similar issue though that seemed to be resolved by a new SST upgrade. Thinking that I've likely missed a step with the V2 migration or have mismatching versions of SST somewhere in my settings
    t
    • 2
    • 2
  • m

    Meris Tarhanis

    05/10/2022, 12:58 PM
    Hello everyone. I have been trying to implement Sentry on my project following this guide: https://serverless-stack.com/examples/how-to-use-sentry-to-monitor-your-serverless-app.html. I am trying to implement the wrapper onto my handler.js main function like this:
    Copy code
    import * as debug from "./debug";
    import Sentry from "@sentry/serverless";
    
    const handler = Sentry.AWSLambda.wrapHandler((lambda) => {
      return async function (event, context) {
        let body;
        let statusCode;
    
        // Start debugger
        debug.init(event);
    
        try {
          // Run the Lambda
          body = await lambda(event, context);
          statusCode = body.statusCode || 200;
        } catch (e) {
          // Print debug messages
          debug.flush(e);
    
          body = { error: e.message };
          statusCode = 500;
        }
    
        // Return HTTP response
        return {
          statusCode,
          body: JSON.stringify(body),
          headers: {
            'Access-Control-Allow-Origin': '*',
            'Access-Control-Allow-Headers': '*',
            // "Access-Control-Allow-Credentials": true,
            // "Access-Control-Allow-Methods": "GET, PUT, POST, DELETE, HEAD, OPTIONS",
          },
        };
      };
    })
    
    export default handler
    This function is used by other lambda's to handle API calls, and my problem is that currently It's just sending the REQUEST's but it doesn't return any RESPONSE. Maybe it's something minor that I am missing. If you need any more info I would happily supply.
    t
    f
    • 3
    • 15
  • r

    Robert

    05/10/2022, 1:10 PM
    Morning everyone! I've been trying to give list access to a specific bucket to my lambda. So I tried this
    Copy code
    const uploadPublicBucket = props.uploadPublicBucket;
    apiGateway.addRoutes(this, {
          'GET  /users': {
            function: {
              functionName: `fdm-${id}-${scope.stage}-get-users`,
              handler: 'services/field-data-api/handlers/user.get',
              permissions: [
                'cognito-idp:ListUsers',
                'cognito-idp:DescribeUserPool',
                [uploadPublicBucket.bucketArn, 'ListBucket'],
              ],
            },
          },
        });
    But I get this error when I run
    sst start
    ,
    Error: The specified permissions are not supported.
    I'm pretty sure there's a way that I can give permission to list a specific bucket to a specific lambda function, if anyone has any hint for me I'd appreciated 🙂
    m
    t
    • 3
    • 9
  • n

    Nathan

    05/10/2022, 1:59 PM
    Hi Folks. How do I get the resource name (example:Bucket) for reference in the backend? Is there a way to get it by the ID used to create the resource in the stack?
    a
    f
    • 3
    • 7
  • j

    Jarod Stewart

    05/10/2022, 3:22 PM
    I am probably blind. Looking for docs around
    sst.json
    with then intent of defining/deploying multiple Apps to different AWS accounts.
    f
    • 2
    • 9
  • l

    Ludovic VUE

    05/10/2022, 7:49 PM
    Hello, I am trying to implement AppSync with a Cognito UserPool primary authorization mode (no x-api-key which seems to be the default mode) I have found this example from the SST documentation: https://docs.serverless-stack.com/constructs/AppSyncApi#using-cognito-user-pool But not sure what the
    userPool
    object is and comes from (as a value). When i look into the CDK
    IUserPool
    interface i am affraid to have to collect and build this massive object! I hope we can do something from the Auth construct return value to build this object. Do you know if it is possible? I didn't find any example of a AppSync + Cognito User Pool Authorization mode example on the web. If we could simply do a
    userPool.attachPermissionsForAuthUsers([api]);
    like for API Gateways it would be really nice!
    f
    • 2
    • 3
  • r

    Robert

    05/10/2022, 8:40 PM
    Hey everyone! Right now I have most of my lambda defined into
    serverless.yml
    , trying to move them over sst but I want to do it over time. As of now, I do use a custom domain for my lambdas in the yaml file. Seed is handling everything with the custom domain. I tried to add a custom domain in my sst apiGateway stack, but it tries to create the custom domain, which I don't want. In the AWS console it is possible to add API mapping on an existing domain. And I was wondering if it is possible with the
    APIGatewayV1API
    object in sst.
    f
    • 2
    • 3
  • s

    Stiofán Ó Lorcáin

    05/11/2022, 7:14 AM
    Hey everyone I have 2 questions about the
    AppSyncApi
    1. My company is requiring all resources in a stack to follow a particular structure. I know you added
    stackName
    to the StackProps to allow for this but it doesn't seem to propagate to the
    AppSyncApi
    , just wondering if there is a way to do this? 2. Is it possible to create a custom
    graphqlUrl
    ? At the moment, it is readonly with no
    set
    method Thanks for any help 🙂
    t
    f
    • 3
    • 6
  • j

    Joel Chan

    05/11/2022, 7:33 AM
    Hello, anyone have use casbin in SST? when i import casbin-node, it shows build error
    Copy code
    Consider changing "parse" to a default import instead:
        node_modules/casbin/lib/esm/persist/helper.js:1:7:
          1 │ import * as parse from 'csv-parse/lib/sync';
    t
    • 2
    • 2
  • f

    Francis Menguito

    05/11/2022, 2:12 PM
    Seems like it’s stuck here or is it doing something?
    t
    f
    • 3
    • 30
  • d

    Dimitri van Hees

    05/11/2022, 2:15 PM
    Hi! I've seen more questions about puppeteer and layers but none of the answers worked for me, so I'm just going to give it a try here... I'm using
    node v14.19.1
    with
    npm 8.9.0
    . Following https://serverless-stack.com/examples/how-to-use-lambda-layers-in-your-serverless-app.html, it throws the error
    Copy code
    Cannot find module '/home/dev/layer-chrome-aws-lambda/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser'.
    This is, by the way, after fixing the
    Cannot find a handler file for "lambda.handler"
    error by moving
    backend/functions/lambda.ts
    to
    backend/lambda.ts
    (I think the tutorial outdated the new directory structure). Removing the
    bundle: { externalModules: ["chrome-aws-lambda"] },
    line results in another error:
    Copy code
    ReferenceError: __dirname is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '/home/dev/layer-chrome-aws-lambda/.sst/artifacts/dev-layer-chrome-aws-lambda-MyStack-Api-Lambda_GET_-/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    I've tried multiple workarounds (including downgrading node and npm versions but that caused a lot of other issues) but none seem to work. Any thoughts? Below are the dependencies of my `package.json`:
    Copy code
    {
      "devDependencies": {
        "@serverless-stack/cli": "^1.0.4",
        "@serverless-stack/resources": "^1.0.4",
        "@tsconfig/node14": "^1.0.1",
        "typescript": "^4.6.4"
      },
      "workspaces": [
        "backend"
      ],
      "dependencies": {
        "chrome-aws-lambda": "^10.1.0",
        "puppeteer": "^14.0.0",
        "puppeteer-core": "^14.0.0"
      }
    }
    m
    • 2
    • 4
  • k

    Karolis Stulgys

    05/11/2022, 3:16 PM
    Hi, how do I do this in functional stack?:
    Copy code
    this.addOutputs({
          ApiEndpoint: this.api.customDomainUrl || this.api.url,
        });

    https://www.youtube.com/watch?v=cqzgAJvUQCg&amp;ab_channel=ServerlessStack▾

    t
    • 2
    • 4
  • m

    Mendel Lerner

    05/11/2022, 3:51 PM
    Hi, The following used to work in SST v0.x
    Copy code
    new RDS(this, 'db', {
          rdsServerlessCluster: {
              credentials: Credentials.fromUsername('admin', {
                secretName: `mySecretName`,
              }),
         }
    })
    With SST v1:
    Copy code
    new RDS(this, 'db', {
          cdk: {
              cluster: {
                  credentials: Credentials.fromUsername('admin', {
                      secretName: `mySecretName`,
                  }),
              }
         }
    })
    throws the following error (Source):
    Copy code
    `Only credentials managed by SecretManager are supported for the "cdk.cluster.credentials".`
    How is this handled differently in SST v1?
    t
    f
    • 3
    • 3
  • n

    Nathan

    05/11/2022, 4:05 PM
    Does anyone know how to map an api gateway in a subaccount to an already created custom domain in a parent account? Is that possible? I’m slowly moving services into environment specific accounts, but the domain will still be registered in the parent. And there are api gateways in that parent account already mapped. so i can’t remove it.
    f
    • 2
    • 4
  • r

    Robert Chandler

    05/11/2022, 5:34 PM
    Has anyone manage to get
    ReportBatchItemFailures
    to work with SQS and SST? I'm wondering if we're doing something wrong or if the live lambda development isn't handling this property correctly. Going to test now with a deployed lambda to check
    f
    • 2
    • 21
  • d

    Damjan

    05/11/2022, 5:49 PM
    Is it possible to use normal Api construct and the graphql interface in console ? I see it’s tagged as graphql: true in metadata but I can’t seem to get it to work.
    t
    • 2
    • 4
  • d

    Dennis Dang

    05/12/2022, 5:06 AM
    When deployed, eventbridge doesn't direct messages to my queue. While locally (with an admin privileged access keys), the whole flow works from bus to queue to lambda. The deployed server that pushes events to the bus uses the same keys as local dev. I've got this setup working a year ago, but can't recall now how to determine if my resources have the correct IAM permissions. Doesn't CDK already handle resource permissions when you set targets?
    t
    f
    • 3
    • 8
  • d

    Dmitry

    05/12/2022, 8:52 AM
    (SOLVED) hi everyone! how can
    sst start
    use
    python
    from local
    conda
    environment? It keeps referring to global
    /usr/local
    installation, which does not have custom packages my guess is that
    sst start
    disregards my terminal environment and just uses an independent process that uses default values and therefore system python setup 🤔
    f
    • 2
    • 3
  • f

    Francis Menguito

    05/12/2022, 2:27 PM
    (SOLVED) Anybody know why there’s no
    ApiEndpoint
    when I started this?
    Copy code
    =======================
     Deploying debug stack
    =======================
    
    
    Deploying stacks
    
     ✅  francis-one-debug-stack (no changes)
    
    
    Stack francis-alloy-one-debug-stack
      Status: no changes
      Outputs:
        BucketArn: arn:aws:s3:::francis-one-debug-stack-bucket83908e77-vbewg8mmew0t
        BucketName: francis-one-debug-stack-bucket83908e77-vbewg8mmew0t
        Endpoint: <wss://wrp9tbyjrk.execute-api.us-east-1.amazonaws.com/francis>
    
    
    ===============
     Deploying app
    ===============
    
    
    Deploying stacks
    
     ✅  francis-one-MyStack (no changes)
    
    
    Stack francis-one-MyStack
      Status: no changes
    
    
    ==========================
     Starting Live Lambda Dev
    ==========================
    
    SST Console: <https://console.serverless-stack.com/one/francis/local>
    Debug session started. Listening for requests...
    t
    f
    • 3
    • 8
  • v

    Victor Garcia

    05/12/2022, 4:39 PM
    [Solved] Hi everybody! I've just upgraded to v1 and everything is compiling ok. However I'm getting a typescript error on the Api construct using a User Pool Authorizer (called 'userPoolAuthorizer'):
    Copy code
    TS2322: Type 'Api<{ userPoolAuthorizer: { type: "user_pool"; userPool: { id: string; clientIds: string[]; }; }; }>' is not assignable to type 'Api<Record<string, ApiAuthorizer>>'.
    Types of property 'createFunctionIntegration' are incompatible.
    Type '(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<"userPoolAuthorizer">, postfixName: string) => HttpRouteIntegration' is not assignable to
    type '(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<string>, postfixName: string) => HttpRouteIntegration'.
    Types of parameters 'routeProps' and 'routeProps' are incompatible.
    Type 'ApiFunctionRouteProps<string>' is not assignable to type 'ApiFunctionRouteProps<"userPoolAuthorizer">'.
    Types of property 'authorizer' are incompatible.
    Type '"none" | "iam" | Omit<string, "none" | "iam"> | undefined' is not assignable to type '"userPoolAuthorizer" | "none" | "iam" | undefined'.
    Type 'Omit<string, "none" | "iam">' is not assignable to type '"userPoolAuthorizer" | "none" | "iam" | undefined'.
    Nevermind, turns out Api now takes a generic:
    Api => Api<{ userPoolAuthorizer: { userPool: { id: string; clientIds: string[] }; type: 'user_pool' } }>
    f
    • 2
    • 2
  • k

    Kujtim Hoxha

    05/12/2022, 5:15 PM
    Is anyone successfully using
    typeorm 0.3
    with SST? I am having trouble getting it to work and I am thinking it has something to do with how sst packages stuff 😅
    t
    n
    • 3
    • 9
  • ö

    Ömer Toraman

    05/12/2022, 5:35 PM
    Hi. We are using Seed for deployment, and our Next application failed to build, which seems to be due to a postinstall script by
    react-jax-parser
    seed.yml
    Copy code
    before_build:
      - echo "Installing NextJS packages"
      - cd frontend && npm ci
    • 1
    • 1
  • j

    Jon Holman

    05/12/2022, 5:41 PM
    I'm trying to follow the guide to upgrade to SST v1.0.2 and I'm stuck on updating my Cron function. I've confirmed that I get the same error with the example from the docs:
    Copy code
    const scheduled = new sst.Cron(this, "Cron", {
          job: "src/lambda.main",
          cdk: {
            rule: {
              schedule: { minute: "0", hour: "4" },
            },
          },
        });
    results in:
    Copy code
    TypeError: _c._bind is not a function
    f
    • 2
    • 3
  • b

    Brinsley

    05/12/2022, 6:12 PM
    Hey guys, started a new project where I wanted to play with Vite and React using an api and mongodb on the backend; decided to use
    ViteStaticSite
    and grab the React plugin. On the client I'm stuck in an endless cycle when calling
    sst-env -- vite
    :
    Copy code
    > frontend@0.0.1 start D:\Git\vite-project\frontend
    > sst-env -- vite
    
    Waiting for SST to start in D:\Git\vite-project...
    Waiting for SST to start...
    Waiting for SST to start...
    Waiting for SST to start...
    Waiting for SST to start...
    Waiting for SST to start...
    ...
    Repeats another 60 times
    Any ideas what's up here? Killed
    .sst
    and
    .build
    folders and no luck 😞
    f
    • 2
    • 5
  • r

    Robert

    05/12/2022, 8:22 PM
    Hey! I'm switching all my stacks to the new functional pattern. Everything works fine but one little thing. Before I used to pass an id to the constructor, this id was used to name the stack in CloudFormation. Now it uses the function name to name the stack. So instead of reusing the old stacks, CloudFormation tries to create new Stack and as you can imagine I do not want to recreate all my cognito userpools, QLDB database, etc etc. Is there a way that I can change the name that the CloudFormation stack will have besides changing the name of the function? As an example, before I was doing this, and the id was used in the name of the CloudFormation
    Copy code
    const fdmCognito = new CognitoStack(app, 'fdm-cognito');
    ...
    constructor(scope, id, props) {
        super(scope, id, props);
    Now I am doing this
    export default function CognitoStack(_ctx_: _StackContext_) {...}
    And instead of the id, it uses
    CognitoStack
    in the name of the CloudFormation stack Thank in advance
    t
    f
    • 3
    • 3
  • r

    Ryan Barnes

    05/12/2022, 8:32 PM
    Hey team, I see you have a lot of monitoring options available for serverless stacks. Wondering if you have any preference?
    b
    f
    • 3
    • 4
  • j

    Jon Holman

    05/12/2022, 9:12 PM
    With the notes demo app and I keep getting this warning:
    Copy code
    Creating an optimized production build...
    Browserslist: caniuse-lite is outdated. Please run:
      npx browserslist@latest --update-db
      Why you should do it regularly: <https://github.com/browserslist/browserslist#browsers-data-updating>
    I have tried those commands, they appear successful, but then I still get this warning again.
    d
    f
    j
    • 4
    • 4
  • s

    Shivansh Yadav

    05/13/2022, 5:02 AM
    is there a way to fix it or the module need to fix their imports?
    t
    • 2
    • 4
  • f

    Francis Menguito

    05/13/2022, 1:21 PM
    Copy code
    Module '"@serverless-stack/resources"' has no exported member 'TableFieldType'.ts(2305)
    m
    f
    h
    • 4
    • 21
  • d

    Devin

    05/13/2022, 2:51 PM
    Non SST related DynamoDB/Lambda Question I have some items in my database that look like this
    Copy code
    pk: 'some-pk'
    sk: 'unique-id'
    active: true
    name: 'cool name'
    
    pk: 'some-pk'
    sk: 'another-unique-id'
    active: true
    name: 'some other name!'
    I have another item that’s essentially a variable grouping of those items
    Copy code
    pk: 'bundle'
    sk: 'unique-bundle-name'
    bundle: ['unique-id', 'another-unique-id']
    I want to “add” a bundle to a customers orders. like…
    Copy code
    // pseudocode
    
    for (const bundle in bundles) {
      const item = await dynamoDb.get(bundle) // get the item by sk
      await dynamoDb.put({...item, customerId })  // put that value into dynamo
    }
    Should I just do that? Another thing I could do is get each item, then transact write the whole batch. I mostly don’t know a good way to do something for a “group” of items. Articles/ideas welcome.
    a
    d
    • 3
    • 5
1...707172...83Latest