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

    Jett Robin Andres

    10/30/2021, 12:14 AM
    I’m trying to update my iam bucket policy statement with the
    Sid
    attribute specified here so I can view my uploaded image urls via browser. I’ve also tried
    PublicReadGetObject
    in my sst setup as I thought there was just a typo upon reading the official docs from aws. However I’m still getting
    AccessDenied
    error for my uploaded images. here’s a snippet from my sst auth stack
    Copy code
    this.auth.attachPermissionsForAuthUsers([
      api,
      new iam.PolicyStatement({
        sid: 'PublicReadGetObject',
        actions: ['s3:*'],
        effect: iam.Effect.ALLOW,
        resources: [
           bucket.bucketArn + '/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*',
           bucket.bucketArn + '/public/*',
           bucket.bucketArn +
             '/protected/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*',
        ],
      }),
    ])
    Here’s my client s3 upload syntax using aws-amplify. Note that I want to remove
    acl
    from my client code. It works on a per-file basis if I uncomment it but I want to rely from sst’s sid instead
    Copy code
    const res = await Storage.put(`${receiptId}.jpg`, blob, {
                contentType: 'image/jpeg',
                level: 'public',
                //acl: 'public-read', //TODO: move acl to sst via sid prop
              })
    f
    • 2
    • 8
  • ö

    Ömer Toraman

    10/30/2021, 2:19 PM
    Hello people. I have this Lambda function for the POST endpoint. I want to write the test for this function, but I’m really not sure how I will mock the
    event
    , and
    EventBridge
    .
    Copy code
    import { EventBridgeClient, PutEventsCommand, PutEventsCommandInput } from '@aws-sdk/client-eventbridge'
    import { StatusCodes } from 'http-status-codes'
    
    import type { APIGatewayProxyHandler } from "aws-lambda"
    
    const eventBridgeClient = new EventBridgeClient({ region: 'eu-central-1' })
    
    export const handler: APIGatewayProxyHandler = async (evt, ctx, cb) => {
          const requestBody = JSON.parse(evt.body)
          const { orderID, price } = requestBody
          //////////
          // Check if the body has required properties
          //////////
          if (!orderID || !price) {
                return {
                      statusCode: StatusCodes.BAD_REQUEST,
                      body: 'Invalid request'
                }
          }
          //////////
          // Put it into EventBridge
          //////////
          try {
                const putEventsCommandInput: PutEventsCommandInput = {
                      Entries: [
                            { EventBusName: 'OrderBus', Detail: JSON.stringify({ id: orderID, price }) }
                      ]
                }
                const putEventsCommand = new PutEventsCommand(putEventsCommandInput)
                const putEventsCommandOutput = await eventBridgeClient.send(putEventsCommand)
                return {
                      statusCode: StatusCodes.CREATED,
                      body: JSON.stringify({ eventID: putEventsCommandOutput.Entries[0].EventId })
                }
          } catch (error) {
                return {
                      statusCode: StatusCodes.ACCEPTED,
                      body: JSON.stringify(error)
                }
          }
    
    }
    t
    r
    +2
    • 5
    • 18
  • t

    Tharshan

    10/30/2021, 5:15 PM
    Hey folks, with the auth0 stack - https://serverless-stack.com/examples/how-to-add-auth0-authentication-to-a-serverless-api.html What method from aws-amplify package do we use to login/redirect to auth0? or do we use the auth0 package directly? (I am using nextjs on front-end)
    f
    • 2
    • 1
  • a

    August C

    10/31/2021, 8:33 PM
    Has anyone had success using SST as part of a larger yarn workspace project? For example, I'd want my SST workspace to have access to the "shared" package in a directory similar to below. This is slightly different than this example where all of the workspaces reside in the SST directory
    Copy code
    /sst
      yarn.lock
      package.json
      [...]
    /shared
      yarn.lock
      package.json
      [...]
    /backend
      yarn.lock
      package.json
      [...]
    yarn.lock
    package.json
    t
    • 2
    • 6
  • g

    Gerald

    11/01/2021, 2:07 AM
    do you have documentation on how to do TDD in serverless stack?
    t
    • 2
    • 7
  • n

    Noah D

    11/01/2021, 7:06 AM
    For anyone who has been using sst with typescript and yarn workspaces, have you ever seen the issue where your lambda code doesn't seem to be transpiling correctly? i.e. when I try to hit my endpoint it gives me the error in local terminal
    SyntaxError: Unexpected token 'export'
    which leads me to believe my code is being interpreted as typescript instead of javascript when it is uploaded to AWS. I am largely following the setup described in this repo but attempting to have separate workspaces for each service/core lib. I might just be overcomplicating this and should be resorting back to just having the whole backend folder as a workspace, but if I can get it working that would be cool. My current tsconfig for the services is in screenshot #1. And my base tsconfig file is in screenshot #2. Any thoughts/resources on this would be helpful. Been trawling through the ts handbook, but no luck so far 😅
    p
    • 2
    • 1
  • s

    Sahan Amadoruge

    11/01/2021, 2:27 PM
    can't we have like this?
    Copy code
    const bucket = new Bucket(this, "Bucket", {
      notifications: [
        {
          function: "src/notification1.main",
          notificationProps: {
            events: [EventType.OBJECT_CREATED],
          },
        },
        {
          function: "src/notification2.main",
          notificationProps: {
            events: [EventType.OBJECT_CREATED],
          },
        },
      ],
    });
    Or what is the best way to call different functions on same event?
    t
    f
    • 3
    • 19
  • l

    Louis Barclay

    11/01/2021, 5:54 PM
    Can I reference a module as the path for a NextjsSite I want to deploy with sst? Currently I get an error on the below code (
    The system cannot find the path specified.
    ), perhaps because node_modules is not recognized as a directory due to being in .gitignore. Possible I am making a basic mistake. My use case is: • Want to deploy a NextjsSite from a separate repository, which I have installed into
    node_modules
    • That'll let me be able to develop the separate repository cleanly - I'll update it when I need to - instead of having to have the whole source code for my Next.js app inside the
    sst
    project
    Copy code
    import * as sst from "@serverless-stack/resources";
    
    export default class MyStack extends sst.Stack {
      constructor(scope, id, props) {
        super(scope, id, props);
    
        // Create a Next.js site
        const site = new sst.NextjsSite(this, "cloakist-notion-nextjs", {
          path: "node_modules/cloakist-notion-nextjs",
          environment: {
            // Pass the table details to our app
            REGION: scope.region,
          },
        });
    
        // Show the site URL in the output
        this.addOutputs({
          URL: site.url,
        });
      }
    }
    t
    f
    • 3
    • 24
  • e

    Erik Robertson

    11/01/2021, 6:52 PM
    Hello all. In my stack definition, I use HttpUserPoolAuthorizer by default and that works fine on all protected routes. On one of those routes instead of receiving the token as usual via the request Headers I need to receive the token as part of the GET parameters in the url (in the form http://my_url?auth_token=xxx). Is there any way to do that with SST/gateway API ?
    g
    f
    c
    • 4
    • 11
  • a

    Adrian Schweizer

    11/01/2021, 9:03 PM
    My definitions from .env file are undefined for some reason. I'm doing this to pass them into the lambda functions in SST index.js file:
    Copy code
    app.setDefaultFunctionProps({
          environment: {
             APP_DOMAIN: process.env.APP_DOMAIN,
             EMAIL_FROM: process.env.EMAIL_FROM,
          },
       });
    t
    j
    f
    • 4
    • 6
  • t

    Tharshan

    11/01/2021, 9:24 PM
    Hey folks - with nextjs site and local images - is that supported out of the box with the nextjs construct? This is how I am using it - https://nextjs.org/docs/basic-features/image-optimization#local-images My images used with the local path are not loading in the cloudfront url
    f
    m
    • 3
    • 12
  • h

    heyysaiii

    11/02/2021, 3:41 AM
    How to sign up when link is used instead of verification code ? Hey, In the chapter https://serverless-stack.com/chapters/signup-with-aws-cognito.html, instead of confirmation code I have used confirmation link for sign up. What should be my flow of code instead of the following for the same? async function handleConfirmationSubmit(event) { event.preventDefault(); setIsLoading(true); try { await Auth.confirmSignUp(fields.email, fields.confirmationCode); await Auth.signIn(fields.email, fields.password); userHasAuthenticated(true); history.push("/"); } catch (e) { onError(e); setIsLoading(false); } }
    f
    • 2
    • 11
  • g

    Gerald

    11/02/2021, 12:41 PM
    Hi, is there a way to do this in SST?
    Copy code
    const serverless = require('serverless-http');
    const express = require('express')
    const app = express()
    
    app.get('/', function (req, res) {
      res.send('Hello World!')
    })
    
    module.exports.handler = serverless(app);
    t
    h
    • 3
    • 10
  • c

    Colin Cheung

    11/02/2021, 3:25 PM
    Just wondering if anyone has gotten mikro-orm setup with serverless stack? After following the setup process for mikro-orm I'm getting build errors:
    Copy code
    node_modules/@mikro-orm/core/utils/Configuration.js:230:61: error: Could not resolve "@mikro-orm/mongodb" (mark it as external to exclude it from the bundle)
        230 │ ...Name: 'MongoDriver', module: () => require('@mikro-orm/mongodb') },
            ╵                                               ~~~~~~~~~~~~~~~~~~~~
    
     > node_modules/@mikro-orm/core/utils/Configuration.js:232:65: error: Could not resolve "@mikro-orm/mariadb" (mark it as external to exclude it from the bundle)
        232 │ ...me: 'MariaDbDriver', module: () => require('@mikro-orm/mariadb') },
    I'm using mysql driver and its the only driver that doesn't error since I've installed it, wondering why this is happening and if I need to maybe use a custom esbuild config?
    t
    • 2
    • 9
  • s

    samer ewidat

    11/02/2021, 4:00 PM
    hello everyone, this is my first day working using SST, when hitting the command
    npx sst start
    the following problem occurs.
    Copy code
    Look like you're running sst for the first time in this directory. Please enter a stage name you'd like to use locally. Or hit enter to use the one based on your AWS credentials (samer): 
    Using stage: samer
    Preparing your SST app
    Transpiling source
    Linting source
    
    =======================
     Deploying debug stack
    =======================
    
    Deploying stacks
    
     ❌  samer-notes-debug-stack failed: The samer-notes-debug-stack stack failed to deploy.
    
    
    Stack samer-notes-debug-stack
      Status: failed
      Error: The samer-notes-debug-stack stack failed to deploy.
    Cannot convert undefined or null to object
    any thoughts?!
    t
    f
    • 3
    • 11
  • a

    Adrian Schweizer

    11/03/2021, 1:15 AM
    is there a best practice how to transport table names created from storage stacks to lambdas that have to access them? I haven't found a solution yet that I'm satisfied with...
    m
    • 2
    • 14
  • s

    Sahan Amadoruge

    11/03/2021, 10:59 AM
    I created a Topic and added two subscribers to it. Then i added that topic to my s3bucket notifications. In the First time i tested i got a SNSEvent to my Lambda function. But now I'm getting a S3Event 🙄 Is it possible?
    Copy code
    const topic = new sst.Topic(this, "imagePut", {
          subscribers: [
            {
              function: {
                handler: "src/s3/resize-image.main",
              },
            },
            {
              function: {
                handler: "src/s3/analize-image.main",
              },
            },
          ],
        });
    
    const bucket = new sst.Bucket(this, "Bucket", {
          s3Bucket: {
            bucketName: `${scope.stage}-absc-files`,
          },
          notifications: [
            {
              topic: topic,
              notificationProps: {
                events: [s3.EventType.OBJECT_CREATED],
                filters: [{ prefix: "original-images/" }],
              },
            },
          ],
    });
    f
    • 2
    • 2
  • j

    joe

    11/03/2021, 12:02 PM
    Am looking for a way to have a full-stack SST app that integrates nicely with the pattern of having Authentication completely handled by an ALB. This pattern is described in the blog - https://www.figma.com/blog/inside-figma-securing-internal-web-apps/
    • 1
    • 2
  • j

    John Nguyen

    11/03/2021, 1:05 PM
    Hi, I am wondering if you also support Lambda with Container Support for the
    API
    - construct? Or how would you do that? I have a FastAPI- app and would like to put it in a Lambda. An ECS with a loadbalancer having API gateway is a bit too much for me...
    a
    t
    • 3
    • 5
  • e

    Erik Robertson

    11/03/2021, 3:03 PM
    I just upgraded SST to 0.50.2 and I'm getting runtime errors. They all seem related to my using Sequelize. I don't use typescript in my own code.
    error  Require statement not part of import statement  @typescript-eslint/no-var-requires
    I tried adding this at the top of the file :
    Copy code
    /* eslint-disable no-eval */
    but no difference. Any other idea ?
    t
    • 2
    • 6
  • m

    Matt LeRay

    11/03/2021, 3:43 PM
    Is there a way to capture API calls or network traffic going into or out of the lambda? My use case is traffic mirroring for playback in my CI environment. Essentially, I’m trying build a cheap version of writing test cases by using stuff we’ve already recorded. I’m very (very) new to SST so forgive my ignorance if I missed something obvious - I also realize this is most definitely an edge case.
    f
    • 2
    • 3
  • c

    Colin Cheung

    11/03/2021, 3:50 PM
    Does anyone know why after adding a VPC to my lambda it causes the lambda to reach the max timeout? I'm trying to setup the VPC so that I can use RDS Proxy
    Copy code
    // Import VPC
    const existingVpc = ec2.Vpc.fromLookup(this, "VPC", {
       vpcId: "vpc-XYZ",
    });
    
    // Sample function to connect function to VPC
    function: {
        handler: "src/claim/index.handler",
        permissions: claimPermissions,
        vpc: existingVpc,
        allowPublicSubnet: true,
    },
    I can see that the VPC is correctly attached in AWS console on the lambda page, but running lambda causes it to timeout
    t
    f
    s
    • 4
    • 21
  • t

    Tharshan

    11/03/2021, 4:09 PM
    Quick question about the prisma example here - https://github.com/serverless-stack/serverless-stack/tree/master/examples/prisma Would this stack code change if the prisma client was being used from within a nextjs app? and used in combination with a NextjsSite struct?
    t
    • 2
    • 11
  • j

    justindra

    11/03/2021, 4:34 PM
    I recently had to do a database migration where we combined 3 different tables into a single one, basically originally we came from an SQL-based system and now using DynamoDB, so data structures need to change. We ended up just writing a stack that we deploy, run the functions, let the migration run, and then remove that stack once we are happy with it. But just wondering if anyone has a better way of doing that? The main issue we had was if anything failed and we need to reverse it. It's fine in this instance as its a brand new table and we can always clear it or remove the table and start again, but if we were running a migration into the same table, that may not be the case.
    r
    t
    • 3
    • 3
  • s

    Sahan Amadoruge

    11/03/2021, 5:37 PM
    Sorry this isn't related to sst. I need to do a multipart file upload inside a Lambda function. Lambda is triggered by the S3 bucket on image upload. Need to get the uploaded image and then send it to another API service.Any suggestions?
    r
    • 2
    • 14
  • d

    Dan Van Brunt

    11/03/2021, 6:59 PM
    Have I setup something wrong with SST liveEdit dev? Whenever we edit/save a lambda handler SST does update/build the code, however if you edit a local dependency of that handler SST does NOT update.
    t
    • 2
    • 2
  • m

    Mike McCall

    11/03/2021, 8:08 PM
    Has anybody encountered this issue?
    @next/swc-darwin-arm64 not accessible from next
    Next is not installed in the project, this is an sst dependency. I am running into this issue in code build running
    npm ci
    t
    f
    • 3
    • 18
  • d

    Dan Van Brunt

    11/03/2021, 8:58 PM
    Is there a way to manually trigger a lambda via SST? Would be AMAZING if there was a way to do this in dev mode directly from VSCode, hotkey or button
    t
    o
    f
    • 4
    • 7
  • p

    Patrick Gold

    11/03/2021, 9:26 PM
    Is it possible to get the SST debugger working with python lambdas in vscode? I’ve only seen node examples. How are you all debugging python code?
    t
    k
    • 3
    • 2
  • s

    Steven Cao

    11/03/2021, 9:30 PM
    Hi folks. I am trying to follow the guide for Material UI on replacing the existing style engine with styled-components https://mui.com/guides/styled-engine/ which relies on module aliasing to get the styled-components hooked up correctly. Is it possible to do that with some sort of config as part of the esbuild process in SST?
    t
    • 2
    • 3
1...282930...83Latest