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

    Sam Hulick

    12/15/2021, 5:41 PM
    does anyone have any general guidance on how to set up an SSR app with SST? so basically initial deployment would look like this: • SST creates resources to host the SSR web app (S3, API Gateway, CloudFront) • The SSR application is built/minified (whatever it is.. Nuxt, Vite, etc) • The Lambda function that sits behind API Gateway is deployed (entry point to the app + back-end SSR code) • The front-end portion of the web app is copied to S3
    m
    f
    • 3
    • 5
  • f

    Fazi

    12/15/2021, 6:55 PM
    Hi all, I am trying to make use of AWS lambda layers. I have defined in my stack definition the following:
    Copy code
    /**
         * Lambda function layers
         */
        const layer: any = new lambda.LayerVersion(this, 'integration-lambda-layers-forecast-layer', {
          code: lambda.Code.fromAsset(path.join(__dirname, '..', '..', 'lambda_layers')),
          compatibleRuntimes: [lambda.Runtime.PYTHON_3_8]
        });
    
        /**
         * Lambda Functions
        */
        const createDBTables = new Function(this, 'CreateDBTables', {
          runtime: "python3.8",
          srcPath: "src",
          handler: 'create_db_tables.handler',
          timeout: 300,
          environment: env,
          permissions: ['ssm', 'rds'],
          description: "do something with rds.",
          vpc: existingVpc,
          securityGroups: [
            functionSecurityGroup
          ],
          logRetention: logs.RetentionDays.ONE_DAY,
          layers: [layer],                                // This line is what seems to be causing the issue
        });
    However, I get the following error message:
    Copy code
    Error: This lambda function uses a runtime that is incompatible with this layer (nodejs12.x is not in [python3.8])
    In my index.ts file I have:
    Copy code
    import * as cdk from "@aws-cdk/core";
    
    
    import MyStack from "./MyStack";
    import * as sst from "@serverless-stack/resources";
    
    export default function main(app: <http://sst.App|sst.App>): void {
      // Set default runtime for all functions
      app.setDefaultFunctionProps({
        runtime: "python3.8",
      });
    
      const stack = new MyStack(app, "stack");
    
      cdk.Tags.of(stack).add("CfStackName", app.name);
      cdk.Tags.of(stack).add("Organisation", 'asas');
      cdk.Tags.of(stack).add("Department", 'asas');
      cdk.Tags.of(stack).add("Environment", app.stage);
    }
    Can someone please explain why it throws that error - is there some sort of configuration missing? Given I am running a python lambda function, and the lambda layer is also in python, why does it need a nodejs runtime too?
    t
    • 2
    • 4
  • d

    Dennis Dang

    12/15/2021, 10:21 PM
    Our event bus rules do have source specified, however I'm encountering this error
    Copy code
    Failed to fetch resources. TypeError: pattern.source[0].startsWith is not a function
        at /Users/dennisdang/Desktop/canopy/api/node_modules/@serverless-stack/cli/scripts/util/ConstructsState.js:326:30
        at Array.filter (<anonymous>)
        at ConstructsState.buildEventBusData (/Users/dennisdang/Desktop/canopy/api/node_modules/@serverless-stack/cli/scripts/util/ConstructsState.js:322:8)
        at runMicrotasks (<anonymous>)
    Example rule construct that I logged. The source is nested inside event pattern json.
    Copy code
    {
          Name: 'xxxx',
          Arn: 'xxxx',
          EventPattern: '{"detail-type":["Failed New Payment Request"],"source":["canopyapi.payment_request"]}',
          State: 'ENABLED',
          EventBusName: 'xxxx'
        },
    f
    • 2
    • 2
  • j

    João Pedro

    12/15/2021, 10:52 PM
    hey @thdxr @Frank is it possible to run the
    build
    command and then, only with the
    .build
    folder results execute the deployment (without the originating project)?
    t
    • 2
    • 9
  • k

    Krizza

    12/16/2021, 7:34 AM
    Hello, how would I initialize a lambda that has no triggers? It’s actually triggered by SNS but we have multiple SNS topics and from different accounts and it will continue to scale up. The only example I saw required me to create an SNS topic first and then adding the lambdas in the subscribers property
    b
    f
    • 3
    • 5
  • j

    Jack G

    12/16/2021, 10:42 AM
    Are there any AWS gurus out there that would be able to provide me with resources / info on how I could accomplish a job queue / processing system using AWS? (I'm thinking SNS/SQS?) I'm just not sure how the interaction should work with the project I have in mind where a user uploads an excel file via a frontend, the job is created and the excel file is processed and the rows are looped through and some API calls to a 3rd party service are executed as a job (via lambdas?) with other jobs (either using the same process or different types of jobs) and then when the job is complete maybe a notification can be sent to a frontend. Is this the right sort of process for the project? I'd like it to be fairly scalable and wont really know much about the throughput until it's in action. Any thoughts, info, ideas or pseudo-code would be very appreciated. I'm a young dev still learning much about the AWS platform 😄
    m
    m
    • 3
    • 5
  • p

    Paul

    12/16/2021, 12:17 PM
    Hey, since updating to 0.54.2
    sst deploy
    fails with the following error:
    Error: There was a problem transpiling the Lambda handler.
    sst start
    is working normally and all lambdas are compiling and running. Deploy also works when I remove my
    esbuildConfig
    . It looks like this:
    esbuildConfig: { plugins: "config/esbuild.js" }
    and contents of esbuild.js:
    Copy code
    const { esbuildDecorators } = require("@anatine/esbuild-decorators");
    
    module.exports = [esbuildDecorators()];
    Any ideas? I know it would be helpful to get more detailed log output, but the
    --verbose
    flag does not provide more info on the error.
    t
    • 2
    • 8
  • j

    Joshua Sparks

    12/16/2021, 5:27 PM
    Hello! I was wondering if anybody here knew if there was a way to run linter at the beginning of build script, and if the linter fails cancel the build? I’m seeing options to turn linting off all together, but i’m trying to make it still run the linter on
    sst build
    but just fail and not finish the build if there are errors. Is this possible?
    t
    • 2
    • 1
  • s

    Surf Turf

    12/16/2021, 5:57 PM
    Hi, installed latest version of sst (0.54.4) run following steps:
    Copy code
    1. npx create-serverless-stack@latest sst-examples --language typescript
    2. cd sst-examples
    3. npm run start
    Got following error:
    Copy code
    /MASKED_PATH/node_modules/@serverless-stack/cli/scripts/start.js:322
            result.error.stackTrace?.join("\n")
                                    ^
    
    SyntaxError: Unexpected token '.'
        at wrapSafe (internal/modules/cjs/loader.js:1072:16)
        at Module._compile (internal/modules/cjs/loader.js:1122:27)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
        at Module.load (internal/modules/cjs/loader.js:1002:32)
        at Function.Module._load (internal/modules/cjs/loader.js:901:14)
        at Module.require (internal/modules/cjs/loader.js:1044:19)
        at require (internal/modules/cjs/helpers.js:77:18)
        at Object.<anonymous> (/MASKED_PATH/sst-examples/node_modules/@serverless-stack/cli/bin/scripts.js:59:16)
        at Module._compile (internal/modules/cjs/loader.js:1158:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    Any idea about the problem? Version 0.53.x works just fine
    r
    f
    • 3
    • 4
  • s

    Surf Turf

    12/16/2021, 6:10 PM
    I'm prototyping AppSyncApi, is there some example how to add api / resolver caching to appsync app? Aws has cloudformation template of resolver/caching but cdk does not have construct for it yet
    • 1
    • 1
  • h

    Haider Abbas

    12/16/2021, 6:36 PM
    Hey Folks, I am looking for some advice for one of my production workloads got mail from aws for shutting down some services and force to use new services.
    Copy code
    We detected AWS AppSync APIs in your account leveraging GraphQL real-time subscriptions sending traffic based on our v1 protocol (MQTT over WebSockets) in the past 12 months. This is our final reminder on December 30, 2021, MQTT over WebSockets will be disabled for all AppSync APIs in all regions in favor of pure WebSockets.
    
    Our recommended best practice is to have your APIs taking advantage of the v2 protocol (pure WebSockets) released in November 2019. We ask that you to update to pure WebSockets by December 30, 2021 to avoid any impact to existing applications. The update is easy and should only take minutes. Simply upgrade your clients to the latest AppSync SDK or Amplify clients for JavaScript/iOS/Android. The pure WebSockets v2 engine is used by default with the latest versions. The Amplify DataStore, which is a multi-platform (iOS/Android/React Native/Web) on-device persistent storage engine that automatically synchronizes data between mobile/web apps and the cloud, also uses our pure WebSockets protocol by default.
    Please suggest me from where i start. I found the code snippet of above services in our code (web, mobile and api’s) Great Thanks! for your precious time
    g
    f
    • 3
    • 3
  • s

    Slackbot

    12/16/2021, 8:46 PM
    This message was deleted.
    t
    d
    c
    • 4
    • 8
  • t

    Tony J

    12/17/2021, 12:56 AM
    Hi Everyone, Was going through the SST example of social-cards (https://serverless-stack.com/chapters/dynamically-generate-social-share-images-with-serverless.html) and it uses lambda layers to drive chrome-aws-lambda and puppeteer. We have a similar use case for chrome-aws-lambda but using the layer results in 25-32 seconds of total time. Separately, we tried a no lambda layer approach using serverless.com and packaging up an instance of chrome using a .zip which resulted in 5-10 second execution time. So now weWe couldn’t figure out how to get the chrome-aws-lambda to work without a non-layer
    f
    j
    • 3
    • 3
  • i

    Ilia Reingold

    12/17/2021, 2:18 AM
    Oh I think I just realized it. You can use
    auth.cognitoUserPool
    to get the cdk methods :D
    f
    • 2
    • 1
  • i

    ipsherman

    12/17/2021, 5:08 PM
    Just starting going through the guide, and I'm getting a really weird error in the Create a Hello World API. When running the
    npx sst start
    command, I get the following error/stack trace (replacing stuff specific to my operating system with
    os-stuff
    ):
    Copy code
    /os-stuff/notes/node_modules/@serverless-stack/cli/scripts/start.js:308
            result.error.stackTrace?.join("\n")
                                    ^
    
    SyntaxError: Unexpected token '.'
        at wrapSafe (internal/modules/cjs/loader.js:1047:16)
        at Module._compile (internal/modules/cjs/loader.js:1097:27)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
        at Module.load (internal/modules/cjs/loader.js:977:32)
        at Function.Module._load (internal/modules/cjs/loader.js:877:14)
        at Module.require (internal/modules/cjs/loader.js:1019:19)
        at require (internal/modules/cjs/helpers.js:77:18)
        at Object.<anonymous> (/os-stuff/notes/node_modules/@serverless-stack/cli/bin/scripts.js:59:16)
        at Module._compile (internal/modules/cjs/loader.js:1133:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    I've done very little so far, just ran the
    npx create-serverless-stack@latest notes
    command, `cd`'d into the directory, and changed the region to
    us-west-2
    . I did just update npm in case that affects anything. Any assistance would be greatly appreciated! Thanks!
    g
    t
    • 3
    • 5
  • t

    Tonny (sstNerd)

    12/17/2021, 7:01 PM
    Hey guys good morning, I’ve a scenario here, not sure if it’s actually a common one or not on dynamodb (nosql dbs) so here I go: If I’ve tables for inventory items (let’s say cars), invoices and companies, do I need to create one
    this.table_{something} = new Table(
    for each table in dynamodb? Is that how it should work or would you do everything in one table? (if so, then how?) Note: I’m aware I can “nest” data for example:
    car.invoices = []
    and have the invoices there, but for the companies (makers), if I want to pull them dynamically from a table then it makes me some noise
    s
    a
    +3
    • 6
    • 15
  • a

    Abdul Taleb

    12/17/2021, 7:44 PM
    Hi All, It seems like after our team adopted SST, our cloudwatch bill has increased significantly. Anyways on lowering cloudwatch fees?
    g
    r
    f
    • 4
    • 8
  • s

    Sam Hulick

    12/17/2021, 9:39 PM
    is there any way in SST to include external files in the local
    .sst/artifacts/<hash>
    folder? so for example.. I have a single Lambda handler right now, and that shows up in that folder as
    src/lambda.js
    . I’ve run a separate build process before running
    yarn start
    , and I want to have those resulting files copied into the same folder as the
    lambda.js
    file. is that doable?
    t
    f
    • 3
    • 12
  • g

    Gabriel Araújo

    12/17/2021, 11:06 PM
    trying to create a websocket api..
    Copy code
    ApiEndpoint: <https://5hnofpe0i5.execute-api.us-east-1.amazonaws.com>
    
    Stack gabiras-coffee-menu-websocket
      Status: failed
      Error: CloudWatch Logs role ARN must be set in account settings to enable logging (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: cacfd1a9-235b-41e8-a17c-3dc8eeaf7845; Proxy: null)
      Helper: This is a common error when configuring Access Log for WebSocket APIs. The AWS API Gateway service in your AWS account does not have permissions to the CloudWatch logs service. Follow this article to create an IAM role for logging to CloudWatch - <https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/>
    m
    f
    • 3
    • 5
  • a

    Adrian Schweizer

    12/19/2021, 6:29 PM
    Does anyone know how to set up a http api route instead of rest, e.g. for returning a pdf? I have seen this: https://docs.serverless-stack.com/constructs/Api#configuring-the-http-api , but don't really understand how to use it.
    f
    • 2
    • 4
  • d

    Devin

    12/19/2021, 7:42 PM
    SOLVED - See thread. I had the trigger written out incorrectly. When someone signs up for my app I want to create a row in the dynamodb table for them. Seems like the use case for a postConfirmation trigger. Here’s what I’ve set up.
    Copy code
    // Create a HTTP API
        this.api = new sst.Api(this, "Api", {
          defaultAuthorizationType: "AWS_IAM",
          defaultFunctionProps: {
            environment: {
              TABLE_NAME: customersTable.tableName,
            },
          },
          // prettier-ignore
          routes: {
            "POST     /profile":         "src/profile/createProfile.main", // this isn't really doing anything but I thought maybe it would help
         }
       })
    
       this.api.attachPermissions([customersTable]);
    
       const auth = new sst.Auth(this, "Auth", {
          cognito: {
            userPool: {
              signInAliases: { email: true },
            },
            defaultFunctionProps: {
              timeout: 20,
              environment: { TABLE_NAME: customersTable.tableName },
              permissions: [customersTable],
            },
            lambdaTriggers: {
              postAuthentication: "src/profile/createProfile.main",
            },
          },
        });
    Really all that happens in
    createProfile.main
    right now is a console log. import handler from “../utils/handler”; import dynamoDb from “../utils/dynamodb”;
    Copy code
    export const main = handler(async (event) => {
      console.log("[44m%s[0m", `--(event--${JSON.stringify(event)}-----`);
    But I can’t see that on signUp. Which i guess sorta makes sense because that’s a service that’s outside of Live Lambda development maybe? How can I log out the event so I can figure out what I want in my table?
    r
    b
    • 3
    • 9
  • m

    mkarsene

    12/20/2021, 7:55 AM
    Hi, I keep getting "Failed to send response because lambda function us disconnected", together with a lambda timeout error, the timeout is 10s. This happens randomly it seems. Then afterwards, I get "The security Token included in the request is expired" but then it it works a few minutes later. I get these errors but in the background, the operation completes somehow. EG if I write to a dynamodb table, I get the errors above, (disconnected, timeout, security token) but when I check the table. The data has been written?? I had recently updated to the latest sst version then when these issues cropped up, I downgraded to my original version. But still I got these issues. Another side effect is that, lambdas are invoked twice. For instance, sending an sms or an email, I receive two emails and two sms...
    t
    j
    j
    • 4
    • 28
  • e

    Erik Robertson

    12/20/2021, 9:04 AM
    Hello all. I'm trying to reduce the set of AWS permissions given to the sst user and doing so using the policy generator to analyze what's being used. The one thing that troubles me is that SST seems to require things like iam:PutRolePolicy and iam:AttachRolePolicy and I believe I can't restrict the resources it needs that on since roles are being created for every lambda etc... Therefore I imagine that if that user gets breached then someone ill-intended could escalate their own privileges. Any recommendations or documented approach to best handling the policy given to the SST user ?
    f
    • 2
    • 4
  • s

    Sam Hulick

    12/20/2021, 5:55 PM
    I can’t seem to get provisioned concurrency to work:
    Copy code
    currentVersionOptions: {
                  provisionedConcurrentExecutions: 1,
                },
    I made that change to the
    sst.Function
    , and it results in no changes to the stack 🤔
    p
    t
    • 3
    • 6
  • v

    vinash

    12/20/2021, 7:49 PM
    Hi, I'm new to sst and going through the (great) serverless stack guide and witness some strange behavior. Whenever I add an API (get, list, delete, etc.), after deployment which is triggered automatically by "sst start", when I trigger the function through curl, sst start fails with the error below:
    Copy code
    TypeError: Cannot read properties of undefined (reading 'send')
        at Object.send (/Users/********/Applications/notes/node_modules/@serverless-stack/core/dist/cli/FunctionBuilder.js:57:21)
        at WS.handleRequest (/Users/********/Applications/notes/node_modules/@serverless-stack/cli/scripts/start.js:253:21)
        at WS.<anonymous> (/Users/********/Applications/notes/node_modules/@serverless-stack/core/dist/runtime/ws.js:100:41)
        at Generator.next (<anonymous>)
        at /Users/********/Applications/notes/node_modules/@serverless-stack/core/dist/runtime/ws.js:8:71
        at new Promise (<anonymous>)
        at __awaiter (/Users/********/Applications/notes/node_modules/@serverless-stack/core/dist/runtime/ws.js:4:12)
        at WS.handleMessage (/Users/********/Applications/notes/node_modules/@serverless-stack/core/dist/runtime/ws.js:62:16)
        at WebSocket.<anonymous> (/Users/********/Applications/notes/node_modules/@serverless-stack/core/dist/runtime/ws.js:59:49)
        at WebSocket.emit (node:events:390:28)
    Then when I run "sst start" again everything works just fine. And that sst start from the commandline states that no changes were deployed. If I add another api when sst start is not running and then do sst start which triggers the deployment everything works fine as well. So it seems like there is some state in memory in the local development server that doesn't work well when adding new API's. Any ideas what's causing this?
    f
    t
    • 3
    • 6
  • t

    Tonny (sstNerd)

    12/20/2021, 8:57 PM
    Good morning everyone, just trying to get some thoughts/ideas on how you guys ‘feed’ (or seed) your database for dev (local) purposes? There are some scenarios where you build something that you need to spin up with some pre-seeded data so you can go straight and work on your features around that data, is there any well adopted approach for do this? It's also helpful when you introduce new developers in your team so they can just spin up the app and they can replicate some behavior (with pre-seeded data) since the first minute they just spin up the app on their side
    r
    g
    +2
    • 5
    • 16
  • d

    David Garcia

    12/20/2021, 9:05 PM
    Hi there, I've been looking for info on what can be throwing this error during deploys / builds
    Error: There was a problem transpiling the lambda handler
    and then further down
    There was an error synthesizing your app
    I would love to provide more info on this but the stack trace isn't indicating where the error is coming from in my code. I am trying to integrate gremlin-js library within a lambda function, whenever I remove the code to query my gremlin server, it seems to deploy just fine. Outside of that, I don't know the exact reason for why this could be occurring. If I could get some more clarity on the above 2 errors, I might be able to narrow down the issue further on my end.
    r
    f
    • 3
    • 10
  • s

    Sam Hulick

    12/20/2021, 9:10 PM
    someone remind me how to properly rename/move functions in CDK? it’s such a pain
    Copy code
    ❌  dev-microservices-api-base failed: Export dev-microservices-api-base:ExportsOutputFnGetAttGetPresentationReelFuncE29CE098ArnD35372FB cannot be deleted as it is in use by dev-microservices-api-public and dev-microservices-api-reels
    I removed all references to this function! I even removed the function itself
    m
    f
    • 3
    • 4
  • s

    Sam Hulick

    12/20/2021, 9:29 PM
    is there any way to speed up this process? something we can do on our end in configuration?
    t
    g
    f
    • 4
    • 17
  • s

    Sam Hulick

    12/20/2021, 10:55 PM
    I’m confused on getting Lambda provisioned concurrency working w/ API Gateway (HTTP API). I’ve figured out how to set up prov. concurrency on a function, but API Gateway is still pointing to the
    $LATEST
    version of the function. how do I make it point to the specific version? and more importantly, how do I ensure that when I update the code and the Lambda version gets bumped, that anything else that depends on that Lambda func updates its reference? I would think if I create an SST function using provisioned concurrency and i pass that function as an API route, it the API Gateway integration would point to the version, but it doesn’t
    f
    h
    j
    • 4
    • 55
1...363738...83Latest