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

    José Ribeiro

    06/04/2021, 9:13 PM
    btw another interesting error today when deploying to prod (hence new env) 😛 any hypothesis about it?
    Copy code
    [100%] fail: Bucket named 'cdk-hnb659fds-assets-***-us-east-2' exists, but not in account ***. Wrong account?
    f
    • 2
    • 7
  • j

    José Ribeiro

    06/04/2021, 10:11 PM
    maybe I’ll sound too silly suggesting something that’s unreasonable, but would it be possible for the sst script to write an environment variable that’s going to be used by other process? (Namely, whatever executing the python code in my case). The use case is this: an environment variable is used to pass a
    bucketName
    from the CDK script to the lambda function. However, when that’s executed locally, the environment definition in
    function.environment
    doesn’t get applied (only when this is deployed) and thus I’m stuck with my env vars defined locally. Therefore, my questions are 1) should SST be defining those env vars instead? 2) if not, would you guys have any suggestions on how to make the stack output available to my python code?
    m
    r
    +2
    • 5
    • 27
  • j

    José Ribeiro

    06/07/2021, 7:20 PM
    is there any way to integrate with https://github.com/hashicorp/terraform-cdk at this point?
    f
    • 2
    • 2
  • b

    Bill Koch

    06/07/2021, 8:24 PM
    Hey All! Has anyone been able to create a CDK RestApi in one stack and share it with other stacks in the project? Here's my setup:
    Copy code
    // index.ts
    import PeopleStack from './people-stack';
    import PlanetsStack from './planets-stack';
    import SharedStack from './shared-stack';
    import * as sst from '@serverless-stack/resources';
    
    export default function main(app: <http://sst.App|sst.App>): void {
      app.setDefaultFunctionProps({
        runtime: 'nodejs12.x'
      });
    
      const shared = new SharedStack(app, 'shared-stack');
      new PeopleStack(app, 'people-stack', shared);
      new PlanetsStack(app, 'planets-stack', shared);
    }
    Copy code
    // shared-stack.ts
    import * as sst from '@serverless-stack/resources';
    import { IRestApi, RestApi } from '@aws-cdk/aws-apigateway';
    
    export default class SharedStack extends sst.Stack {
    
      public readonly restApi: IRestApi;
    
      constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
        super(scope, id, props);
    
        this.restApi = <IRestApi> new RestApi(this, `${scope.stage}-sst-demo`);
      }
    }
    Copy code
    // people-stack.ts
    import * as sst from '@serverless-stack/resources';
    import SharedStack from './shared-stack';
    
    export default class PeopleStack extends sst.Stack {
      constructor(scope: <http://sst.App|sst.App>, id: string, shared: SharedStack, props?: sst.StackProps) {
        super(scope, id, props);
    
        const api = new sst.ApiGatewayV1Api(this, "Api", {
          restApi: shared.restApi,
          routes: {
            "GET /people/{id}": "src/people/lambda.handler",
          },
        });
    
        this.addOutputs({
          "ApiEndpoint": api.url,
        });
      }
    }
    Copy code
    // planets-stack.ts
    import * as sst from '@serverless-stack/resources';
    import SharedStack from './shared-stack';
    
    export default class PlanetsStack extends sst.Stack {
      constructor(scope: <http://sst.App|sst.App>, id: string, shared: SharedStack, props?: sst.StackProps) {
        super(scope, id, props);
    
        const api = new sst.ApiGatewayV1Api(this, "Api", {
          restApi: shared.restApi,
          routes: {
            "GET /planets/{id}": "src/planets/lambda.handler",
          },
        });
    
        this.addOutputs({
          "ApiEndpoint": api.url,
        });
      }
    }
    With the above setup, I get the following error when trying to `npx sst build`:
    Copy code
    Error: 'dev-sst-demo-shared-stack' depends on 'dev-sst-demo-people-stack' (dev-sst-demo-shared-stack -> dev-sst-demo-people-stack/Api/Lambda_GET_--people--{id}/Resource.Arn). Adding this dependency (dev-sst-demo-people-stack -> dev-sst-demo-shared-stack/dev-sst-demo/Resource.Ref) would create a cyclic reference.
        at PeopleStack._addAssemblyDependency (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/stack.ts:730:13)
        at Object.addDependency (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/deps.ts:52:20)
        at PeopleStack.addDependency (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/stack.ts:485:5)
        at resolveValue (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/refs.ts:100:12)
        at Object.resolveReferences (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/refs.ts:30:24)
        at Object.prepareApp (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/prepare-app.ts:31:3)
        at Object.synthesize (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/synthesis.ts:24:3)
        at App.synth (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/stage.ts:180:23)
        at App.synth (/Users/kochwm/dev/sst/sst-demo/node_modules/@serverless-stack/resources/src/App.ts:199:33)
        at process.<anonymous> (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/app.ts:123:45)
    Any help would be greatly appreciated!
    f
    • 2
    • 7
  • s

    steve gates

    06/07/2021, 9:18 PM
    Quick question! our dynamodb is not referenced in config. So how does it connect with our frontend? Is it through the serverless.yml file? If so, why do we connect through serverless.yml when everything else connects through config.js? Thanks so much 🙂
    f
    • 2
    • 6
  • s

    Sam Frampton

    06/07/2021, 11:01 PM
    Hey, quick question for serverless community. I signed up to a Serverless Enterprise Account and then deleted my account. Every time I now deploy to Seed I get build failed the error. Does anyone know of the sls command to switch off Serverless Pro ask for login?
    Copy code
    ERROR: Serverless Pro Error: You are not currently logged in.
    f
    • 2
    • 4
  • j

    José Ribeiro

    06/09/2021, 7:43 PM
    if a function is defined within a queue/topic, how can I recover the function reference from within the queue/topic to use it elsewhere (e.g. in a clouwatch alarm)?
    f
    • 2
    • 3
  • t

    thdxr

    06/10/2021, 3:05 PM
    and aggregate results
    f
    • 2
    • 13
  • a

    Ashishkumar Pandey

    06/10/2021, 10:14 PM
    Hey everyone, I have a query, how can I use top level await in sst with typescript. I did switch the module system from 
    commonjs
     to 
    esnext
     and I’m already targeting 
    es2018
     . I also did switch my function runtime to use Node 14.x but I still get transpilation error saying that top-level await isn’t supported, any ideas?
    j
    • 2
    • 6
  • a

    Albert Gao

    06/11/2021, 5:06 AM
    what is the version of aws cdk should i use with sst? latests? or 1.105?
    f
    • 2
    • 1
  • b

    Bill Koch

    06/11/2021, 6:37 PM
    Hey All - I'm trying deploy my SST application to an existing RestApi in AWS. I was able to follow the example for importing an existing RestApi into SST, but I can't seem to get my resources associated to a stage/deployment in the RestApi. Here's my stack:
    Copy code
    // MyStack.ts
    import * as sst from "@serverless-stack/resources";
    import { Deployment, RestApi, Stage } from "@aws-cdk/aws-apigateway";
    
    export default class MyStack extends sst.Stack {
      constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
        super(scope, id, props);
    
        const apiGateway = RestApi.fromRestApiAttributes(this, "MyRestApi", {
          restApiId: "8w6b74ksx0",
          rootResourceId: "6lhf5t9hje",
        });
    
        const deployment = new Deployment(this, `${scope.stage}-deployment`, {
          api: apiGateway
        });
    
        const stage = new Stage(this, `${scope.stage}-stage`, {
          deployment: deployment,
          stageName: scope.stage
        });
    
        apiGateway.deploymentStage = stage;
    
        // Create a HTTP API
        const api = new sst.ApiGatewayV1Api(this, "Api", {
          restApi: apiGateway,
          importedPaths: {
            "/serverless": "tvg3ia"
          },
          routes: {
            "GET /serverless/hello": "src/lambda.handler",
          },
        });
      }
    }
    Any help would be greatly appreciated!
    f
    r
    • 3
    • 35
  • a

    Albert Gao

    06/13/2021, 1:57 AM
    Will API Gateway always put any querystring as a string? (I’m using HTTP API) Or this is something I can configure in cdk?
    f
    r
    • 3
    • 13
  • m

    Mr.9715

    06/13/2021, 10:44 AM
    Hey guys, Is it possible to reuse an existing CloudFront distribution? I have 2 separate CDK apps the first creates a CloudFront dist which also has a custom domain associated with it, serving a static website. I have another s3 website that I want behind the same CloudFront (and use the same custom domain name) and I want to associate a behavior (admin & admin/*) to it. I am able to achieve the desired result manually by updating Cloudfront from the console. Unable to do it from CDK.
    Copy code
    const distribution = cloudfront.Distribution.fromDistributionAttributes(this, name('cdn'), {
                distributionId: cdk.Fn.getAtt(name('distName'), 'app1devDistID'),
                domainName: siteDomain
            });
    The above code works but this
    distribution
    object doesn't have any methods. only a few properties.
    f
    • 2
    • 10
  • a

    Ashishkumar Pandey

    06/13/2021, 5:52 PM
    Can anyone advice on how should I go about testing my APIs using jest?
    r
    • 2
    • 15
  • s

    Simon Reilly

    06/14/2021, 7:36 AM
    Hey, I want to use the
    sst.Auth
    construct, but I don't need an identity pool. reason for using the construct is; it handles permissions for triggers, creates the user pool, creates the app client, has sensible defaults. Reason I am not using identity pools is because I am working with multi-tenancy and need to create policies for data isolation. Is there any way to turn identity pool generation off for the Auth construct?
    f
    • 2
    • 10
  • m

    Mitja O

    06/14/2021, 12:02 PM
    Hi guys, I’m trying to add prisma (https://www.prisma.io/) to a lambda and trying to deploy it. I have an issue because prisma requires a binary be present in the lambda source. That is not included in the build and it errors out. Is there a way to add the required binary to the bundled package? With serverless fw. this can be achieved with a custom post-install script written in bash, bu t I’m unsure on how to tackle this with SST 🤔
    r
    f
    a
    • 4
    • 10
  • a

    Artem Kalantai

    06/14/2021, 2:16 PM
    Hi, the question isn’t directly related to sst, but how can I merge google identity user in cognito with the usual cognito identity with the same email to 1 user?
    f
    • 2
    • 7
  • m

    Mr.9715

    06/15/2021, 4:28 AM
    Hey Guys, I am having hard time initialing this mono repo approach with aws cdk...😅 I have 1 TS CDK backend, 2 TS react frontends and our usual TS lambdas in src with their own package.json files. Looking for help with yarn workspace and/or lerna
    a
    f
    • 3
    • 9
  • g

    gio

    06/15/2021, 5:48 AM
    Hello guys, I would like to know what is your experience in Netlify. I see it is a service suggested in Serverless Stack, I would understand Pro and Cons between this service and a solution based on Cloudfront+S3. I always used Cloudfront+S3 to host my Angular apps, I was going to use Netlify but after the last feature in SST (the SiteStatic constructor) I thought it could be a better solution than hosting in Netlify.
    f
    j
    • 3
    • 6
  • t

    Tomasz Michalak

    06/15/2021, 10:11 AM
    Hello guys, do you have an example with
    CloudFront
    and the
    Api
    construct?
    m
    • 2
    • 5
  • t

    thdxr

    06/15/2021, 2:12 PM
    Is it pascal case?
    f
    m
    • 3
    • 7
  • t

    thdxr

    06/15/2021, 3:05 PM
    From googling I see examples loading secrets into environment variables - this doesn't seem secure to me and seems like it negates the point of using secret manager.
    s
    j
    +2
    • 5
    • 19
  • d

    Dennis Dang

    06/16/2021, 6:31 AM
    Is anyone else using lambda authorizers to handle their auth? Is live lambda dev working for you? After the first try, under the assumption that my authorizer is setup correctly, the lambda errors out with 500s. I’ll share more code snippets in the morning. Hoping I can recreate this.
    f
    • 2
    • 7
  • g

    Gabriel

    06/16/2021, 8:39 AM
    Hi, I was wondering can I import already existing Auth cognito?
    f
    • 2
    • 15
  • a

    Alejandro Inestal

    06/17/2021, 12:51 PM
    Hi, is there any guide to enable husky in sst with typescript? To avoid committing without the lint passing
    f
    j
    • 3
    • 4
  • a

    Alex Price

    06/17/2021, 3:28 PM
    Does AppSync support resolver level auth? I'm using Auth0 and the SST docs show route level
    authorisationType
    , but I can't see it mentioned for AppSync.
    f
    • 2
    • 12
  • d

    Dan Van Brunt

    06/17/2021, 4:23 PM
    First off, thanks for the great framework core team! Anyone know of a way to add
    cache-control
    settings to files uploaded by StaticSite? The issue is when those cache control settings are very specific, like with gatsbyjs. I can only seem to get it to work on FIRST upload if I use.. 1. 3x deployments 2. order the deployments with deps 3. prune only on first deploy However, on preceeding deploys, if you change a file name (or delete file) that impacts only say the 2nd deployment package, then you will have the old file as an orphan. Would LOVE some ideas on how to resolve this limitation. Other things I’ve half-baked-considered: • running aws
    s3 cp bucket bucket
    to retroactively update cache control settings. ◦ many challenges here… ◦ time consuming looping throw assets twice ◦ can’t be built into a Construct (unless rewriting the deploy construct) since it would need to have the target bucket already deployed/created. • using programmatic CDK deploy and using
    execSync
    to upload the assets AFTER CDK deploys. Special Note: It appears that
    aws cli's s3 sync
    --delete option takes into account the whole directory of files and NOT just the ones the command is filtering on. However, `s3deploy.BucketDeployment`’s prune option ONLY takes into account the filtered files. This is the crux of the issue. That and there seems to be no way to have 1x single deployment that handles multiple sources “and their associated cache control settings”. Anyone with experience with this stuff with some ideas, please share. Cheers!
    f
    • 2
    • 36
  • g

    Gabriel Gordon-Hall

    06/17/2021, 7:39 PM
    Hi, I’m trying to use Knex with SST. It works when I run it locally with
    sst start
    , but when I run
    sst deploy
    I get the following error:
    Copy code
    2021-06-17T19:18:15.874Z	undefined	ERROR	Uncaught Exception 	{
        "errorType": "Runtime.ImportModuleError",
        "errorMessage": "Error: Cannot find module '../../dialects/postgres/index.js'\nRequire stack:\n- /var/task/invoke.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
        "stack": [
            "Runtime.ImportModuleError: Error: Cannot find module '../../dialects/postgres/index.js'",
            "Require stack:",
            "- /var/task/invoke.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"
        ]
    }
    It’s odd because I can see
    knex/lib/dialects/postgres/index.js
    in my node modules folder. I also have pg installed. I have tried explicitly importing pg in my lambda but to no avail. Here’s the lambda code:
    Copy code
    import Knex from "knex";
    const pgEnv = process.env.POSTGRES || "";
    const config = {
      client: "pg",
      connection: pgEnv,
    };
    const knex = Knex(config);
    I found a webpack workaround for this error is to add the following to the `webpack.config.js`:
    Copy code
    module.exports = {
      entry: slsw.lib.entries,
      target: "node",
      externals: { knex: "commonjs knex" },
    };
    Is there a similar workaround that would be compatible with SST? Thanks!
    r
    t
    c
    • 4
    • 9
  • s

    Simon Reilly

    06/18/2021, 6:28 AM
    Got a strange error with event bridge and sst.Function this morning.
    Copy code
    Error: Cannot find asset at /home/simon/code/projects/event-bridge/.build/lib/runtime
        at new AssetStaging (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/core/lib/asset-staging.ts:170:13)
        at new Asset (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:127:21)
        at AssetCode.bind (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/code.ts:277:20)
        at new Function3 (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/function.ts:583:29)
        at SingletonFunction.ensureLambda (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:134:12)
        at new SingletonFunction (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:56:32)
        at new AwsCustomResource (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:360:22)
        at new LogGroupResourcePolicy (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts:34:5)
        at CloudWatchLogGroup2.bind (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-events-targets/lib/log-group.ts:38:7)
        at Rule2.addTarget (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-events/lib/rule.ts:166:32)
    When running
    sst test
    the lambda gets built correctly:
    Copy code
    $ tree -L 1 .build/
    .build/
    ├── eslint.js
    ├── lib
    ├── run.js
    ├── src-lambda-main-1623997587633
    ├── sst-debug.log
    └── sst-merged.json
    When running deploy the lambda does not build
    sst deploy
    Copy code
    $ tree -L 1 .build/
    .build/
    ├── cdk.out
    ├── eslint.js
    ├── lib
    ├── run.js
    ├── sst-debug.log
    ├── sst-merged.json
    └── sst-start-cache.json
    • 1
    • 1
  • m

    Mr.9715

    06/19/2021, 4:29 PM
    Hey guys, I am trying to use middy for lambda validation. I was also using handler-lib approach before this.( really liked it! ) I tried wrapping middy with handler but it throws callback error. What is the good way of configuring this? I used both of them together because: • cors • I want to format my error responses as in jsend.
    a
    f
    s
    • 4
    • 10
1...678...83Latest