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

    Kujtim Hoxha

    05/13/2022, 3:13 PM
    @thdxr I was trying out https://github.com/serverless-stack/kysely-data-api and I am having an interesting issue, what is the type of a
    json
    field supposed to be, I am hitting the WTF here šŸ˜› (using mysql)
    t
    • 2
    • 13
  • l

    Leo Hick

    05/13/2022, 3:33 PM
    Hello everyone. Looking for some advice on this: • I have one domain (ie: https://www.mydomain.com) and will have multiple SST frontend projects for separate business needs. • How can I have these multiple SST frontend projects distributed like that? ā—¦ https://www.mydomain.com/application1 ā—¦ https://www.mydomain.com/application2 ā—¦ https://www.mydomain.com/application3 Any ideas on how to accomplish that? Thanks in advance!
    d
    f
    a
    • 4
    • 28
  • d

    Dan Van Brunt

    05/13/2022, 3:51 PM
    Should we be able to view a copied file in
    bundle copyFiles
    LiveEdit/Dev mode for
    sst.Function
    ?
    Copy code
    bundle: {
                  copyFiles: [
                    {
                      from: './eventSchema.js',
                      to: 'schemas/eventSchema.js',
                    },
                  ],
                },
    This doesn’t seem to work for us…
    Copy code
    const getDirectories = (source: string) =>
      fs
        .readdirSync(source, { withFileTypes: true })
        .filter((dirent) => dirent.isDirectory())
        .map((dirent) => dirent.name)
    
    const things = getDirectories(__dirname)
      console.log(things)
    getting
    []
    for directories
    f
    t
    • 3
    • 7
  • a

    Anthony Sanchez

    05/13/2022, 11:12 PM
    hey there, I've noticed some odd behavior so just wanted to get some clarification if possible. SST runs functions locally, correct? so if I'm performing http calls in a function, they're originating from machine? This appears to be manifesting itself in that live lambda development works on one machine but not another.
    a
    f
    • 3
    • 6
  • t

    T Indie

    05/14/2022, 1:48 PM
    Does anyone know how to connect to the AWS RDS PostgreSQL database using PgAdmin, I can access the "Query Editor" as described here via the secrertARN provided by SST, however to connect using PgAdmin a "master password" is needed, any idea how to find it? or if anyone knows a better way to connect to pgAdmin? Thanks in advance
    f
    r
    • 3
    • 4
  • f

    Fatih ErdinƧ

    05/14/2022, 5:30 PM
    Hi, i define two tables like that,
    Copy code
    const domainLogsTable = new sst.Table(this, process.env.TABLE_DOMAINLOGS, {
        fields: {
            id: sst.TableFieldType.STRING,
            domainName: sst.TableFieldType.STRING,
            time: sst.TableFieldType.NUMBER
        },
        primaryIndex: {partitionKey: "id"},
        globalIndexes: {
            domainNameIndex: {partitionKey: "domainName", projection: "all", sortKey: "time"}
        },
        dynamodbTable: {
            removalPolicy: RemovalPolicy.DESTROY,
        },
    });
    
    const domainTable = new sst.Table(this,process.env.TABLE_DOMAIN, {
       fields: {
           domainName: sst.TableFieldType.STRING
       },
       primaryIndex: {partitionKey: "domainName"}
    });
    
    const api = new sst.Api(this, "Api", {
        routes: {
            "GET /": "src/lambda.handler",
        },
        defaultFunctionProps: {
            permissions: [domainTable,domainLogsTable]
        }
    });
    but i get accessdeniedexception when put item to dynamodb
    i
    • 2
    • 3
  • b

    Boris Tane

    05/14/2022, 5:31 PM
    I might be wrong but this piece of code from the documentation seems to not work as intended:
    Copy code
    import { StringParameter } from "aws-cdk-lib/aws-ssm";
    
    const rootDomain = StringParameter.valueForStringParameter(this, `/myApp/domain`);
    
    new ApiGatewayV1Api(this, "Api", {
      customDomain: {
        domainName: `api.${rootDomain}`,
        hostedZone: rootDomain,
      },
      routes: {
        "GET /notes": "src/list.main",
      },
    });
    I get this
    Copy code
    Error: Cannot determine scope for context provider hosted-zone.
    This usually happens when one or more of the provider props have unresolved tokens
    it works only when the
    hostedZone
    is a hardcoded string and not the value from ssm parameter store. my dev deps:
    Copy code
    "@serverless-stack/cli": "^1.1.0",
    "@serverless-stack/resources": "^1.1.0",
    "@tsconfig/node14": "^1.0.1",
    "@types/aws-lambda": "^8.10.70",
    "@types/node": "<15.0.0",
    "aws-cdk-lib": "2.24.0"
    f
    s
    • 3
    • 9
  • s

    Schuyler Sloane

    05/14/2022, 8:16 PM
    Is it just me or is there a mistake in the Rest-api-example? I keep getting stubborn type errors on get.ts and update.ts and my code is exactly the same as what is presented on the page
    t
    • 2
    • 23
  • s

    Schuyler Sloane

    05/14/2022, 10:19 PM
    Ok so I have been having another set of problems with the Golang version of the rest example. Any hints as to what might be causing the issue here would be very much appreciated.
    t
    f
    • 3
    • 40
  • j

    Jimmy

    05/15/2022, 8:56 AM
    how do I do these kinds of tests with functional stacks? https://github.com/serverless-stack/serverless-stack/blob/e46c10609349fe3ab916db11[…]b9f4e20daf8/packages/cli/test/template-app/test/MyStack.test.js e.g.
    Copy code
    import { Template } from "aws-cdk-lib/assertions";
    import * as sst from "@serverless-stack/resources";
    import MyStack from "../lib/MyStack";
    
    test("Test Stack", () => {
      const app = new <http://sst.App|sst.App>();
      // WHEN
      const app = app.stack(MyStack)
      // THEN
      try {
        const template = Template.fromStack(stackIsMissingHere);
        template.resourceCountIs("AWS::Lambda::Function", 1);
        // Print out a test string that parent .test.js can catch
        console.log("JESTTESTSUCCESS-----");
      } catch (e) {
        // Ignore any errors
      }
    });
    t
    a
    f
    • 4
    • 12
  • d

    Devin

    05/15/2022, 4:59 PM
    Are there any examples use SST with Playwright or Cypress, ideally with Seed CI/CD? I’d like to set up some e2e tests
    o
    • 2
    • 1
  • c

    Christian

    05/15/2022, 7:45 PM
    Getting this error when I try to build:
    error: panic: Expected scope (6, 2125)  in <FILEPATH>, found scope (6, 1649)
    I’ve searched the github repos of sst, esbuild, etc. but nothing comes up. I’ve tried every combination of tsconfig I can think of and none work, reduced the API stack down to just one fn and I still get it… I’m at a loss. Has anyone seen this? I’ve attached the full log.
    r
    f
    • 3
    • 4
  • t

    Tobias T

    05/16/2022, 9:12 AM
    Hey! I have set up a new
    Queue
    and Im trying to publish messages to it. Getting the following error.
    Copy code
    UnknownEndpoint: Inaccessible host: `my-queue-name' at port `undefined'. This service may not be available in the `eu-north-1' region.
    I have passed in
    queueUrl
    as this example (https://github.com/serverless-stack/serverless-stack/blob/master/examples/queue/stacks/MyStack.ts)
    Copy code
    environment: {
                queueUrl: queue.queueName,
              },
    t
    f
    • 3
    • 11
  • m

    Meris Tarhanis

    05/16/2022, 9:55 AM
    Hello everyone, I am having an issue with deployed version of my app. In the local environment (when I run the stage with
    npx sst start
    ) everything works correctly, but when I try to use the deployed version of my app (be it via auto Seed deployment or
    npx sst deploy
    ) my API is not working at all. Does anyone know what might be the issue?
    f
    • 2
    • 2
  • m

    Miguel

    05/16/2022, 12:24 PM
    Hi everyone. I am trying to update sst from version
    0.69.7
    to
    1.1.1
    I changed my stack for a functional stack and managed to make it deploy properly. However, although I installed
    vitest
    and tried to fix my tests it seems I’m doing something wrong since I keep getting an error when I run
    npm test
    The error is located in this line:
    const goLambda = new lambda.Function(stack, 'triggerRawToProcessJobGo', {
    environment,
    runtime: lambda.Runtime.GO_1_X,
    handler: 'ingestion',
    layers: [appConfigLayer],
    code: lambda.Code.fromAsset('src/backend/mainmodule',
    ....
    }),
    });
    it says this:
    Error: Failed to bundle asset dev-my-app/triggerRawToProcessJobGo/Code/Stage, bundle output is located at /private/var/folders/jf/4x6j7wjd7vv57m6q_n0458b00000gn/T/cdk.out2KAJkC/asset.15f36b77f48997c8703e2300c8a640d5fdb2eddc95f4eb4607c00b74a8bc8053-error: TypeError [ERR_INVALID_OPT_VALUE]: The value "WritableWorkerStdio {
    _writableState: WritableState {
    objectMode: false,
    highWaterMark: 16384,
    finalCalled: false,..." is invalid for option "stdio"
    It looks to me that it might be related to a
    path
    issue in the
    code
    property. Some difference between the test framework and the normal deployment. But it was working as is before the upgrade so I’m having issues solving it. Thanks for any help!
    t
    f
    • 3
    • 16
  • t

    Tobias T

    05/16/2022, 12:39 PM
    Does anyone have any examples of using OneTable together with SST?
    t
    a
    • 3
    • 4
  • r

    Ross Coundon

    05/16/2022, 2:23 PM
    I have a problem where a handler is being bundled with lots of code that is not referenced by that handler or by anything in its dependency tree. The structure we have is that there is a handlers folder, each file in there exports 1-to-many handlers. These handlers are pretty thin and call a service layer specific to their business logic. The reason I noticed this particular handler was bundling seemingly everything is that it barely does anything; simply calculating a value based on some inputs and returning but was erroring due to missing env vars for things it doesn’t reference. It’s like esbuild isn’t treeshaking at all. Does anyone have any idea of what could be causing that?
    t
    • 2
    • 5
  • t

    Trey Overton

    05/16/2022, 2:41 PM
    @Frank We have an NPM package where we have a lot of utility functions we use across multiple apps. I have attempted to put an SST stack into that package, but as soon as I include any form of "import { ... } from '<our package>';", resulting Lambda functions fail to execute when deployed (via Seed) with an error:
    Copy code
    "Error: Cannot find module 'punycode/'\nRequire stack:\n- /var/task/src/lambda.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js"
    Oddly, when testing the function locally, it works fine, but when deployed via Seed, it does not. I am lost as to where to go look to resolve this. Any suggestions?
    t
    • 2
    • 16
  • m

    Meris Tarhanis

    05/16/2022, 2:51 PM
    Hello everyone, a bit of clarification on my last question. I have some API endpoints in which lambdas I have imported these two packages:
    Copy code
    import { fileTypeFromBuffer } from 'file-type';
    import AWS from 'aws-sdk';
    When I try sending a request to any of those endpoints, I get this error message from lambda CloudWatch log:
    Copy code
    2022-05-16T14:45:28.071Z	undefined	ERROR	Uncaught Exception 	
    {
        "errorType": "Runtime.ImportModuleError",
        "errorMessage": "Error: Cannot find module 'node:fs'\nRequire stack:\n- /var/task/src/endpoints/files/create.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
        "stack": [
            "Runtime.ImportModuleError: Error: Cannot find module 'node:fs'",
            "Require stack:",
            "- /var/task/src/endpoints/files/create.js",
            "- /var/runtime/UserFunction.js",
            "- /var/runtime/index.js",
            "    at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
            "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
            "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
            "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
            "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
            "    at Module.load (internal/modules/cjs/loader.js:863:32)",
            "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
            "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
            "    at internal/main/run_main_module.js:17:47"
        ]
    }
    I suspect that Node's filesystem is not importing these packages correctly. Any suggestion on what might be the problem and/or how to fix it?
    t
    t
    • 3
    • 20
  • a

    AdriƔn Mouly

    05/16/2022, 7:19 PM
    Hey guys, I just upgraded to the latest SST, creating a new project from scratch. I’m using
    StaticSite
    . Before the upgrade, I had the following config with ā€œalternateNamesā€ and ā€œcertificateā€. I see some breaking changes adding
    cdk
    object, but still getting an error?
    f
    • 2
    • 5
  • g

    Garret Harp

    05/16/2022, 10:10 PM
    Has anyone here setup cognito with google login? I am trying to ensure that only one account will ever exist for a user so whenever someone tries to login with google if they do not already have a cognito native account I will create one and then link them but for some reason I get an error on the login that user already exists so I have to double login. Not sure how to go about fixing this, anyone know?
    m
    f
    • 3
    • 11
  • l

    lgupta

    05/17/2022, 3:50 AM
    Hi everyone, I have the following config for creating API's and it works locally
    Copy code
    defaults: {
          function: {
            environment,
            vpc: vpc,
            vpcSubnets: {
              subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
            },
            bundle: {
              externalModules: ['pg', 'better-sqlite3', 'mysql2']
            }
          }
        },
    But the above does not work when I try to deploy with seed.run
    Copy code
    Error: There was a problem transpiling the Lambda handler: > node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:80:68: error: Could not resolve "pg" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
        80 │ ... const pgModule = await Promise.resolve().then(() => require('pg'));
           ╵                                                                 ~~~~
     > node_modules/kysely/dist/cjs/dialect/sqlite/sqlite-driver.js:68:72: error: Could not resolve "better-sqlite3" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
        68 │ ...ule = await Promise.resolve().then(() => require('better-sqlite3'));
           ╵                                                     ~~~~~~~~~~~~~~~~
     > node_modules/kysely/dist/cjs/dialect/mysql/mysql-driver.js:99:71: error: Could not resolve "mysql2" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
        99 │ ...mysqlModule = await Promise.resolve().then(() => require('mysql2'));
    Please let me know if there is anything else that I need to add to the config. Thanks cc: @thdxr @Frank
    f
    t
    • 3
    • 5
  • h

    heyysaiii

    05/17/2022, 4:40 AM
    Hey, I am trying to implement the google sign-in in my serverless app, using the docs - https://docs.amplify.aws/lib/auth/advanced/q/platform/js/#google-sign-in-react, but facing an issue ā€œpopup_closed_by_userā€ in every browser. I haven't blocked the cache. Can someone help me in solving please?
    m
    • 2
    • 4
  • c

    Crhistian Caraballo

    05/17/2022, 1:00 PM
    Hey guys, I'm looking for some advice: The scenario: I want to upload bot on ec2 that scrappy some data but it's can take around 20-30 min. So Im trying to use SNS with SQS but I don't know how to subscribe the ec2 instance or how I can send a request to it. Is it possible?
    f
    • 2
    • 2
  • a

    Aleksa Miseljic

    05/17/2022, 1:13 PM
    Hey everyone, can someone help me with setting up jest with SST? I managed to setup and create int test for my main stacks but when try to run my unit tests I get fellowing error:
    d
    f
    • 3
    • 5
  • h

    Harris Newsteder

    05/17/2022, 2:57 PM
    will this be a problem and how do I do a major update through NPM?
    t
    • 2
    • 9
  • h

    Harris Newsteder

    05/17/2022, 8:40 PM
    specifically when following the JWT Auth0 Example I'm getting this error after manually downgrading to 2.20.0 CDK version
    r
    f
    • 3
    • 3
  • a

    Adrian Schweizer

    05/17/2022, 11:22 PM
    Why do I get this console output:
    Copy code
    stacks/StorageStack.js (15,36): Type '"GET"' is not assignable to type 'HttpMethods'.
    13.                   allowedHeaders: ["*"],
    14.                   allowedMethods: ["GET", "PUT", "POST", "DELETE", "HEAD"],
    15.                },
    Seems weird to me, because "GET" is indeed in HttpMethods. Some Typescript thing I'm not getting?
    r
    f
    • 3
    • 13
  • a

    Adrian Schweizer

    05/17/2022, 11:25 PM
    I also get this output I can't figure out why:
    Copy code
    stacks/AuthStack.js (58,23): Object is possibly 'undefined'.
    56.       UserPoolId: auth.userPoolId,
    57.       IdentityPoolId: auth.cdk.cfnIdentityPool.ref,
    58.       UserPoolClientId: auth.cdk.userPoolClient.userPoolClientId,
    I tried to migrate this with the migration guide, which told me to move cognitoCfnIdentityPool ⇒ cdk.cfnIdentityPool
    n
    f
    • 3
    • 8
  • e

    Emanuel Bohnenkamp

    05/18/2022, 12:46 AM
    Hi, I'm porting an app to SST from SAM. I'm using the 'config' package, and it requires for config jsons to be uploaded. I'm not seeing my config folder in the deployed prod app (it works in local with live lambda). am I missing something? maybe define specific files for upload?
    f
    • 2
    • 2
1...717273...83Latest