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

    Daniel Gato

    01/14/2022, 6:08 PM
    Is there a way for pass the StaticSite CDN url to the environments of the StaticSite?
    t
    • 2
    • 6
  • c

    Cam Sloan

    01/14/2022, 7:40 PM
    Hey there - currently trying to run sst start locally. I have set up an Api resource pointing to a lambda, and in that lambda I am trying to use the
    pg
    npm package to make the connection. I have also tried using
    serverless-postgres
    with the same results. I am getting an error about not able to resolve pg-native.
    Copy code
    > node_modules/pg/lib/native/client.js:4:21: error: Could not resolve "pg-native" (mark it as external to exclude it from the bundle, or surround it with try/catch to handle the failure at run-time)
    the code implementation looks like:
    Copy code
    const { Pool } = require('pg')
    // import ServerlessClient from 'serverless-postgres'
    
    const pool = new Pool({
      user: process.env.DB_USER,
      host: process.env.DB_HOST,
      database: process.env.DB_NAME,
      password: process.env.DB_PASSWORD,
      port: Number(process.env.DB_PORT),
      debug: true,
      delayMs: 3000,
    })
    Any help would be greatly appreciated!
    f
    w
    b
    • 4
    • 8
  • m

    Michael Clifford

    01/14/2022, 7:44 PM
    Hey all, so after updating to
    0.59.1
    and following the README steps to the letter, I get the following when running `sst diff`:
    Copy code
    TypeError: Cannot read properties of undefined (reading 'addClient')
        at HttpUserPoolAuthorizer.bind (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@aws-cdk/aws-apigatewayv2-authorizers-alpha/lib/http/user-pool.ts:34:64)
        at new HttpRoute (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@aws-cdk/aws-apigatewayv2-alpha/lib/http/route.ts:139:45)
        at Api.addRoute (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:462:19)
        at /home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:303:12
        at Array.forEach (<anonymous>)
        at Api.addRoutes (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:302:25)
        at new Api (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/node_modules/@serverless-stack/resources/src/Api.ts:272:10)
        at new UsersAPIStack (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/stacks/users_api/UsersAPIStack.ts:29:16)
        at Object.main (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/stacks/index.ts:30:25)
        at Object.<anonymous> (/home/mclifford/Development/github.com/cliffom/sst-bff-demo/.build/run.js:94:16)
    f
    • 2
    • 7
  • j

    Jon Holman

    01/14/2022, 8:36 PM
    huh, I just tried to update to
    0.59.1
    and I got this:
    Copy code
    % npx sst diff
    Using stage: dev
    Preparing your SST app
    Error: Cannot find module 'colors/safe'
    Require stack:
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/diff/types.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/diff/index.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/diff-template.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/index.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/hotswap-deployments.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/deploy-stack.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/bootstrap/deploy-bootstrap.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/bootstrap/bootstrap-environment.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/bootstrap/index.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/index.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/util/asset-publishing.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/cloudformation-deployments.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/context-providers/index.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/plugin.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/aws-auth/credential-plugins.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/aws-auth/sdk-provider.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/lib/api/aws-auth/index.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/bin/cdk.js
    - /Users/jonholman/repos/personal/notes/node_modules/aws-cdk/bin/cdk
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
        at Function.Module._load (internal/modules/cjs/loader.js:725:27)
        at Module.require (internal/modules/cjs/loader.js:952:19)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (/Users/jonholman/repos/personal/notes/node_modules/aws-cdk/node_modules/@aws-cdk/cloudformation-diff/lib/iam/iam-changes.ts:2:1)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
        at Module.load (internal/modules/cjs/loader.js:928:32)
        at Function.Module._load (internal/modules/cjs/loader.js:769:14)
        at Module.require (internal/modules/cjs/loader.js:952:19)
    f
    • 2
    • 5
  • r

    Ross Gerbasi

    01/14/2022, 9:35 PM
    Maybe this will help someone but I am needing to use
    node-fetch
    in my project so I installed it like normal
    npm i node-fetch
    . This gave me v3 which is
    type: module
    only. This should be fine as I am using a TS project and it shouldn't matter much. However I kept getting an error with SST telemetry as it also uses
    node-fetch
    Copy code
    node_modules/@serverless-stack/core/dist/telemetry/post-payload.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
    Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module"
    ``` I disabled telemetry in my SST project but sadly this file still seems to load and cause the error. So for now the only option is to stick with for node-fetch@2. Anyway hope this helps someone.
    t
    f
    c
    • 4
    • 8
  • d

    Dan Van Brunt

    01/14/2022, 10:47 PM
    Having issues getting
    sst.ApiGatewayV1Api
    to NOT validate the incoming request. Previously, I had
    sst.Api
    working as a webhook for Contentful and it worked out of the box. I’ve now setup the same code but in
    sst.ApiGatewayV1Api
    and now I’m getting…
    "__type": "ValidationException", "message": "1 validation error detected: Value null at 'entries' failed to satisfy constraint: Member must not be null"
    I have not set ANY validation on the Api which leads me to believe there is one there by default? How can I fix this issue, as I don’t have any control over the format that Contentful is sending.
    f
    • 2
    • 7
  • a

    Adam Fanello

    01/14/2022, 11:06 PM
    Just noticed, upon an error, that my Typescript source maps aren't working. I know it did before migrating from Serverless Framework. Got
    "sourceMap": true,
    set and
    import "source-map-support/register";
    at the beginning of each Lambda handler. I see
    .js.map
    files being generated, but stack traces are showing .js files with large line numbers. Tips?
    r
    t
    • 3
    • 9
  • r

    Ross Gerbasi

    01/15/2022, 2:16 AM
    SST Dynamo Question, if you have a failed deploy, or maybe delete a stack from the AWS console then go to redeploy with SST it will not happen as it throws a
    table already exists
    error. Does SST have anyway to help with this? Maybe not failing but using the table instead? I guess I worry about down the road, a year from now if something gets messed up, we blow away a stack and redeploy we will have a lot of data in dyanmo. Won't be as simple as delete the table and redeploy.
    c
    f
    • 3
    • 10
  • r

    Ross Gerbasi

    01/15/2022, 4:16 PM
    Just throwing out some more info I have found, not sure if there is a better place to share this stuff... but in reference to https://serverless-stack.slack.com/archives/C01JG3B20RY/p1642141454001700 and @Lukasz K maybe this helps with the request you mentioned you sent in? If you want to create a APIgV2 (httpAPI) and connect it to a domain name but you do not want to use Route53, or maybe you do but you want to merge separate APIs with at the DomainName level, you can use the following. Just to be clear the merging would be if you have
    ApiA
    (xxxyyy.execute-api.region.amazonaws.com) and
    ApiB
    (aaabbb.execute-api.region.amazonaws.com) and you want to end up with
    <http://api.example.com/v1/apia|api.example.com/v1/apia>
    and
    <http://api.example.com/v1/api|api.example.com/v1/api>
    . This could be a much less costly solution then an edge lambda or worker to change requests. I'll throw the code in the thread to not fill up the room here.
    f
    • 2
    • 17
  • f

    Fadi saadeldin

    01/15/2022, 4:18 PM
    Hello, I am working on SQS queue, i want to trigger another lambda when the queue consumer received the message so i can handle the message from the queue, any idea how to do that?
    m
    t
    r
    • 4
    • 8
  • d

    Daniel Gato

    01/15/2022, 7:11 PM
    I have a lambda that is trying to write to my firehose DeliveryStream instance. This permission works:
    Copy code
    'POST    /collect': {
      function: {
        handler: 'src/analytics/create.main',
        environment: {
          ANALYTICS_DELIVERY_STREAM_NAME: analyticsDeliveryStream.deliveryStreamName,
        },
        permissions: [analyticsDeliveryStream],
      },
    },
    When I add it, it says
    Error: The specified permissions are not supported.
    Is there a way to go around it?
    f
    • 2
    • 8
  • d

    Daniel Gato

    01/15/2022, 8:49 PM
    This is a stupid question - in the guide you say to do this:
    Copy code
    export default class ApiStack extends sst.Stack {
      api;
    
      constructor(scope, id, props) {
        super(scope, id, props);
        ...
    Why do we expose api? Is there any requirement of SST for us to do that?
    t
    f
    • 3
    • 6
  • d

    Dan Van Brunt

    01/15/2022, 9:46 PM
    Anyone happen to know if I should assume that CDK v1 - httpApi doesn't support service integrations (
    AWS_PROXY
    ) while v2 does by seeing these docs?
    f
    • 2
    • 5
  • d

    Dan Van Brunt

    01/16/2022, 1:07 AM
    What is supposed to re-build during an
    sst start
    when you save a function file. It seems like it rebuilds the whole App? Or at least the current stack in the app? So if you have a StaticSite (React) inside that same stack…. it rebuilds the whole site with he save? Thats what we are seeing…. doesn’t seem like that should be the case though, not, quite efficient? No?
    t
    • 2
    • 1
  • d

    Dan Van Brunt

    01/16/2022, 1:31 AM
    Isn’t
    sst start
    supposed to update the functions (
    sst.Api
    ) live when saving? Right now I can see the console processing after save, but running the function again does not show the changes. Currently, we’re stopping and restarting sst cli in order to see changes. This can’t be whats supposed to happen?
    t
    • 2
    • 19
  • f

    Franco Gotusso

    01/16/2022, 1:47 PM
    Hi there! I'm getting a funny error while running
    sst build
    and I'm wondering if you could help?
    Copy code
    Error: Cannot find asset at /Users/franco/Remi/Repository/remi/.build/lib/runtime
        at new AssetStaging (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/core/lib/asset-staging.ts:109:13)
        at new Asset (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.ts:72:21)
        at AssetCode.bind (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/code.ts:180:20)
        at new Function2 (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/function.ts:350:29)
        at SingletonFunction.ensureLambda (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.ts:119:12)
        at new SingletonFunction (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.ts:41:32)
        at new AwsCustomResource2 (/Users/franco/Remi/Repository/remi/node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:190:22)
        at new DBMigrationStack (/Users/franco/Remi/Repository/remi/infra/src/DBMigrationStack.ts:21:29)
        at Object.main (/Users/franco/Remi/Repository/remi/infra/src/index.ts:16:32)
        at Object.<anonymous> (/Users/franco/Remi/Repository/remi/.build/run.js:94:16)
    I see from other questions that this is usually due missing cdk packages but I'm a bit lost on what to add here since it's us the ones creating the custom resource directly. Also bumped to the last SST version to use CDK2 without success. Any ideas? Here's the snippet:
    Copy code
    import * as sst from "@serverless-stack/resources";
    import * as ec2 from "aws-cdk-lib/aws-ec2";
    import * as cr from "aws-cdk-lib/custom-resources";
    import { StringParameter } from "aws-cdk-lib/aws-ssm";
    
    type NetworkDetails = {
        vpc: ec2.IVpc;
        securityGroup: ec2.ISecurityGroup;
    };
    
    export default class DBMigrationStack extends sst.Stack {
        constructor(scope: <http://sst.App|sst.App>, id: string, networkDetails: NetworkDetails, props?: sst.StackProps) {
            super(scope, id, props);
    
            const DB_NAME = StringParameter.valueForStringParameter(this, "/REMI/DB_NAME");
            const DB_USER = StringParameter.valueForStringParameter(this, "/REMI/DB_USER");
            const DB_HOST = StringParameter.valueForStringParameter(this, `/REMI/DB_HOST/${scope.stage}`);
            const DB_PORT = StringParameter.valueForStringParameter(this, "/REMI/DB_PORT");
    
            // Custom resource is needed here since we cannot fetch secure strings from ssm otherwise
            const DB_PASSWORD = new cr.AwsCustomResource(this, "GetParameter", {
                onUpdate: {
                    // will also be called for a CREATE event
                    service: "SSM",
                    action: "getParameter",
                    parameters: {
                        Name: "/REMI/DB_PASSWORD",
                        WithDecryption: true,
                    },
                    // Update physical id to always fetch the latest version
                    physicalResourceId: cr.PhysicalResourceId.of(Date.now().toString()),
                },
                policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
                    resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
                }),
            });
    
            new sst.Script(this, "Script", {
                onCreate: "core/config/database/migrator.main",
                onUpdate: "core/config/database/migrator.main",
                params: {
                    DB_NAME,
                    DB_USER,
                    DB_PASSWORD: DB_PASSWORD.getResponseField("Parameter.Value"),
                    DB_HOST,
                    DB_PORT,
                },
                defaultFunctionProps: {
                    vpc: networkDetails.vpc,
                    securityGroups: [networkDetails.securityGroup],
                    bundle: {
                        copyFiles: [
                            {
                                from: "core/config/database/migrations",
                                to: "core/config/database/migrations",
                            },
                        ],
                        nodeModules: ["@mikro-orm/core", "@mikro-orm/migrations", "@mikro-orm/postgresql", "knex", "pg"],
                        externalModules: [
                            "@mikro-orm/sqlite",
                            "@mikro-orm/mariadb",
                            "@mikro-orm/mysql",
                            "@mikro-orm/mongodb",
                            "pg-native",
                            "mysql",
                            "sqlite3",
                        ],
                    },
                },
            });
        }
    }
    f
    • 2
    • 5
  • d

    Daniel Gato

    01/16/2022, 2:29 PM
    just did a deploy and the cli tells me it works. It outputs my ReactSite customDomain
    SiteUrl: <https://daniel.app.xxx.io|https://daniel.app.xxx.io>
    . When I try to open this url, I get
    Copy code
    This site can't be reachedCheck if there is a typo in <http://daniel.app.xxx.io|daniel.app.xxx.io>.
    DNS_PROBE_FINISHED_NXDOMAIN
    In my DNS in AWS I have
    Copy code
    <http://daniel.app.xxy.io|daniel.app.xxy.io><http://daniel.app.xxy.io|daniel.app.xxy.io><http://daniel.app.xxy.io|daniel.app.xxy.io>	A	Simple	-	<http://d3u001tpxxxxxx.cloudfront.net|d3u001tpxxxxxx.cloudfront.net>.
    When I try
    <http://d3u001tpxxxxxx.cloudfront.net|d3u001tpxxxxxx.cloudfront.net>
    I get my website. How can I investigate such problems with SST? Is there some documentation or some hints because right now I don’t even know where to start. As a side note, I have a StaticSite on my project and this one works in another subdomain, same for the API
    f
    • 2
    • 5
  • k

    Kristian Lake

    01/16/2022, 7:09 PM
    I have a question. loving the serverless-stack site. Love visiting a site and it making me all excited to run though and absorb all the information. What I want to do is a SPA site, but once a user is logged in, they would go to a backend site. so www.example.com and once logged in using cognito they would be on www.app.example.com I just want to check if the stack supports that and the terminology of the site under app.example.com. I am trying to understand what that site is. its not another SPA is it?
    t
    • 2
    • 8
  • f

    Francois Lachance

    01/16/2022, 7:45 PM
    Hello all! I'm pretty new at this serverless stuff and I do see this as the way of the future. DynamoDB is a bit of a challenge for me given that it's very different than my relational background. My application is in need of what would be normally a lookup table with just under 200 rows. The data is pretty static, meaning it's very unlikely to change. Is this something that would be best practice to setup in a stack - define a DynamoDB table and load it with the static data? Or would it be better to simply create a constant in the code and hard coded values?
    t
    r
    • 3
    • 8
  • k

    Kristian Lake

    01/16/2022, 9:32 PM
    hey all, I have a problem running
    Copy code
    npx sst add-cdk @aws-cdk/aws-iam
    from https://serverless-stack.com/chapters/adding-auth-to-our-serverless-app.html Any ideas?
    t
    f
    • 3
    • 11
  • d

    Dan Van Brunt

    01/17/2022, 2:09 AM
    @Frank @thdxr I noticed SST is now using `“constructs”: “^10.0.29",` (in CDK v2) instead of the previous
    cdk.Construct
    is there a simple explanation for that? Should SST / construct authors being doing the same?
    f
    • 2
    • 8
  • f

    Francois Lachance

    01/17/2022, 3:52 AM
    I think I missed a detail somewhere - I'm trying to start the frontend with "npm start" but got this result:
    Copy code
    > frontend@0.1.0 start
    > sst-env -- react-scripts start
    
    sst-env: Cannot find matching SST environment outputs in D:\Development\fasterbuddy\.build\static-site-environment-output-values.json. Ensure the StaticSite points to D:\Development\fasterbuddy\frontend
    Where should I look to fix this? That output json file that is mentioned in the error message is actually empty.
    m
    t
    • 3
    • 4
  • m

    Marcos Sampaio

    01/17/2022, 7:03 AM
    hi there What would be the proper way to inject database credentials (that is available in SSM parameter store) to a SST lambda?
    f
    • 2
    • 4
  • m

    Mark Faulkner

    01/17/2022, 3:06 PM
    I’m using SST v 0.57.4 and am trying to get the SST Console to work. When i access console.serverless-stack.com and it redirects to my running instance the page that appears is stuck as the “Syncing metadata” loading indicator and not progressing past that. Is there something which I’m missing, as I imagine it should just work and show me the same UI as found here: https://github.com/serverless-stack/serverless-stack/releases/tag/v0.55.0. Any help would be appreciated
    t
    • 2
    • 15
  • k

    Kristian Lake

    01/17/2022, 4:38 PM
    slightly different error now though
    d
    f
    • 3
    • 6
  • d

    Dan Van Brunt

    01/17/2022, 6:06 PM
    [Possible v0.59.1 bug]: I think this bug may relate to changing the name of the stack.
    Copy code
    console.log({ stackName })
      // eg. idx-dvb-idx
      new MyStack(app, serviceName, {
        stackName,
      })
    which results in the debug and main stacks to deploy without error (see photos)… however running
    yarn start --stage dvb-idx
    ends up failing in the command line with
    dvb-idx-idx-idx failed: The dvb-idx-idx-idx stack contains no resources.
    Which looks like one too many “idx”??
    f
    • 2
    • 8
  • a

    Adam Fanello

    01/17/2022, 7:48 PM
    Okay... has anyone solved for this scenario yet? I have my domain model defined in one (or more) OpenAPI spec files with just schema. I have SST creating my Lambdas. I want to generate a new complete OpenAPI spec for each API Gateway, pulling in any referenced domain schema, with the enclosed paths to actual API Gateway endpoints.
    r
    f
    t
    • 4
    • 6
  • t

    thdxr

    01/17/2022, 9:00 PM
    Do you have a static site defined in your stacks?
    k
    n
    • 3
    • 65
  • d

    Dan Van Brunt

    01/17/2022, 9:45 PM
    Anyone have an idea why we would be seeing
    typescript + eslint + prettier
    working perfect in our stack/cdk code…
    /cdk
    but specifically prettier doesn’t seem to work in our
    lambda
    folder… Dir Structure:
    Copy code
    /lambdas/thing1/lambdacode.ts
    /cdk/constructs/thing1.ts
    tsconfig.json
    t
    • 2
    • 16
  • r

    Roberto Novelo

    01/18/2022, 12:34 AM
    Has anyone built or integrated multi tenant domains/ssl alongside NextJS, or point me at any good resources I could dig enough to integrate with SST? e.g. is there any way I can integrate some dynamoDB layer at edge to request and cache certs? or handle DNS resolution for a Next.js site somehow?
    f
    t
    • 3
    • 5
1...424344...83Latest