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

    Adrian Schweizer

    11/03/2021, 11:04 PM
    I have a problem with
    addDefaultFunctionEnv
    Method of app Object. I'm trying to bulk pass table names from storage stack to lambdas by using the method like so: StorageStack:
    Copy code
    export default class StorageStack extends sst.Stack {
       // Use public fields for reference in other stacks
       tables;
    
       constructor(scope, id, props) {
          super(scope, id, props);
    
          this.tables = {
             users: new sst.Table(this, "Users", {
                fields: {
                   // fieldspecs
                },
                // more table specs
             }),
             organisations: new sst.Table(this, "Organisations", {
                fields: {
                   // fieldspecs
                },
                // more table specs
             }),
             ... etc.
    index.js:
    Copy code
    export default function main(app) {
       const storageStack = new StorageStack(app, "storage");
    
       // Add table names to process environment for lambda functions
       const tableNames = {};
       Object.keys(storageStack.tables).forEach((key) => {
          const name = 'TABLE_NAME_' + key.toUpperCase();
          tableNames[name] = storageStack.tables[key].tableName;
       });
       console.log(tableNames);
       app.addDefaultFunctionEnv(tableNames); // If i comment this line out, deployment works
       ... etc.
    t
    m
    • 3
    • 45
  • p

    Pranav Badami

    11/04/2021, 1:01 AM
    hey folks! quick question, does anyone know how i can support configurations for arbitrary stage names in
    serverless.yml
    ? for example, if i want to deploy to a stage like
    dev-pranav
    , is there a way for me to structure this such that i fallback to my
    dev
    stage config? thanks!
    f
    • 2
    • 2
  • g

    Greg Martin

    11/04/2021, 1:29 PM
    Copy code
    There was an error synthesizing your app.
    t
    • 2
    • 29
  • d

    Dan Van Brunt

    11/04/2021, 4:51 PM
    Got this when tearing down (
    npx sst remove
    ) just now…
    Copy code
    Error: No child with id: 'Code'
        at Node.findChild (/Users/me/Projects/projx/node_modules/constructs/src/construct.ts:95:13)
        at ConstructNode.findChild (/Users/me/Projects/projx/node_modules/@aws-cdk/core/lib/construct-compat.ts:215:70)
        at /Users/me/Projects/projx/lib/constructs/ContentfulApp/ContentfulApp.ts:100:50
        at Array.forEach (<anonymous>)
        at new ContentfulApp (/Users/me/Projects/projx/lib/constructs/ContentfulApp/ContentfulApp.ts:97:20)
        at new MyStack (/Users/me/Projects/projx/lib/constructs/MyStack/MyStack.ts:58:5)
        at Object.main (/Users/me/Projects/projx/lib/index.ts:13:3)
        at Object.<anonymous> (/Users/me/Projects/projx/.build/run.js:93:16)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    t
    f
    • 3
    • 43
  • c

    Clayton

    11/04/2021, 5:09 PM
    Just starting to get familiar with using & composing CDK constructs inside SST stacks. Curious, does a stack like this look decently well-formed or are there areas you’d change to make it more performant, succinct, or better leverage SST?
    a
    t
    • 3
    • 2
  • h

    Hamed Mamdoohi

    11/04/2021, 7:37 PM
    Hello SST 👋 do we have an example of direct integration of APIGW to SQS ? I tried to look at all the construct methods on APIGW and SQS and couldn't find anything My worry is that if I use CDK constructs I would lose the local development benefits. Is that true ?
    ö
    t
    • 3
    • 7
  • p

    Patrick Young

    11/04/2021, 7:47 PM
    I'm trying to get a lambda layer of "sharp". Following this example: https://github.com/serverless-stack/serverless-stack/tree/master/examples/bucket-image-resize It seems to be missing the "layers/sharp" folder... what goes in there? The docs say to
    Copy code
    Unzip the packaged layer to this directory.
    Does that mean copy whats in node_modules?
    t
    j
    • 3
    • 12
  • a

    August C

    11/04/2021, 8:05 PM
    From the docs, how is this true [
    [It supports] Lambda IAM permissions, so if a Lambda fails on AWS due to the lack of IAM permissions, it would fail locally as well
    ] if the lambda function is ran locally and only the results are passed back to the stub lambda in AWS?
    t
    • 2
    • 3
  • c

    Clayton

    11/04/2021, 9:19 PM
    I’m not sure how to interpret this top-level IAM role statement from Serverless Framework ↓ How might something like this be reproduced in SST or CDK for a service? Thanks in advance for any help.
    Copy code
    // serverless.yml
    
    provider:
      name: aws
      iamRoleStatements:
        - Effect: Allow
          Action: cloudwatch:PutMetricData
          Resource: '*'
    f
    o
    • 3
    • 6
  • c

    Clayton

    11/04/2021, 9:59 PM
    …and a different question – Is there a smart way to dynamically pass or reference an ARN between separate services (SST projects) in the same AWS account?
    t
    a
    • 3
    • 15
  • g

    Greg Martin

    11/04/2021, 11:04 PM
    When running locally, is this to be expected?
    Copy code
    Unexpected Top Level Error: Error: socket hang up
    t
    • 2
    • 29
  • b

    Boris Tane

    11/04/2021, 11:23 PM
    👋 I just noticed this in the
    sst.Table
    construct: https://github.com/serverless-stack/serverless-stack/blob/cd3829ea4f004675aed8c5a4823ab8ca9198339c/packages/resources/src/Table.ts#L152 it's not super clear in the docs that you can't have something like this
    Copy code
    this.table = new sst.Table(this, "table", {
          fields: {
            pk: sst.TableFieldType.STRING,
            sk: sst.TableFieldType.NUMBER,
          },
          primaryIndex: { partitionKey: "pk", sortKey: "sk" },
          stream: true,
          dynamodbTable: {
            stream: dynamodb.StreamViewType.NEW_IMAGE
          }
        });
    it indeed rejects the stream in
    dynamodbTable
    but I had to dig the code to figure that out, not critical, but worth pointing out 😄
    t
    • 2
    • 4
  • d

    Dan Van Brunt

    11/05/2021, 12:26 AM
    Is there a way to setup an EventBridge eventPattern for something like this…
    Copy code
    event: {
      'detail-type': 'MediaConvert Job State Change',
      source: 'aws.mediaconvert',
      detail: {
        status: 'COMPLETE',
        userMetadata: {
          stackname: 'dev-idx-idx',
        },
      },
    }
    Right now i have this working…
    Copy code
    {
      "detail-type": [
        "MediaConvert Job State Change"
      ],
      "source": [
        "aws.mediaconvert"
      ],
      "detail": {
        "status": [
          "COMPLETE"
        ]
      }
    }
    but I also want to filter on that 
    userMetadata.stackname === 'dev-idx-idx'
    t
    s
    o
    • 4
    • 15
  • s

    Sam Hulick

    11/05/2021, 12:29 AM
    I’m suddenly seeing this on every API request (locally)
    Copy code
    Warning: Ignoring extra certs from `/etc/pki/tls/certs/ca-bundle.crt`, load failed: error:02001002:system library:fopen:No such file or directory
    anyone know what this is?
    t
    o
    +5
    • 8
    • 82
  • p

    Pavan Kumar

    11/05/2021, 10:33 AM
    I am trying to add SST to existing Serverless monorepo. I need to run deployment using
    seed.run
    . I am encountered with this problem. 1. Serverless has a
    api gateway
    defined 2. Newly created SST has
    congnito
    and
    react
    app defined (previously manually deployed) The
    react
    app and
    gateway
    needs to know about
    congnito
    id after congnito gets deployed. The
    react
    app needs to know
    gateway
    url after gateway gets deployed. In other words, I want only
    congnito
    to be created first from SST then
    gateway
    from serverless then
    react
    app from sst. Is there a way to ensure this order in
    seed.run
    ?
    o
    • 2
    • 4
  • p

    Pavan Kumar

    11/05/2021, 10:43 AM
    Won't SST delete
    Auth
    (Cognito) resource from AWS when
    sst remove
    is executed?
    t
    • 2
    • 3
  • a

    Artem Kalantai

    11/05/2021, 11:23 AM
    Hi, maybe some knows what is this ?
    Copy code
    Warning: Ignoring extra certs from `/etc/pki/tls/certs/ca-bundle.crt`, load failed: error:02001002:system library:fopen:No such file or directory
    r
    t
    • 3
    • 3
  • c

    Clayton

    11/05/2021, 3:28 PM
    Serverless-Framework-familiar friends — does this top-level property in a serverless.yml doc need to be declared someway in SST or does SST’s build process already account for what it’s meant to accomplish?
    Copy code
    package:
      individually: true
    m
    r
    j
    • 4
    • 5
  • b

    Boris Tane

    11/05/2021, 5:57 PM
    👋 I might be misunderstanding something but it seems like the event bridge
    addRules
    function has lost some functionality. here we prevent setting up the
    targets
    https://github.com/serverless-stack/serverless-stack/blob/eed6864ee360edeac18312182bcd923ae9e87410/packages/resources/src/EventBus.ts#L19 but it means we cannot set the
    RuleTargetInput
    this is the CF reference for it https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutTargets.html I'm basically trying to set
    InputTransformer
    and
    InputPath
    , any pointers? or should I revert to CF for this?
    t
    f
    +2
    • 5
    • 10
  • j

    justindra

    11/05/2021, 7:33 PM
    I currently have a single stack that has a function used to basically keep track of any changes happening to my DDB tables as an audit log. This function is now pretty stable so it never changes, but when doing a
    sst diff
    it always has to build it first, which takes quite some time. This holds up checking any other changes. Just wondering if anyone has any other ideas other than separating the stack?
    f
    • 2
    • 3
  • ö

    Ömer Toraman

    11/05/2021, 8:22 PM
    Is it possible to use
    Auth
    construct for Cognito User Pool Groups?
    g
    • 2
    • 1
  • g

    Gerald

    11/06/2021, 3:22 PM
    how do you run cdk synth?
    f
    • 2
    • 3
  • ö

    Ömer Toraman

    11/06/2021, 3:35 PM
    Hello. I would like to receive your opinion on something. Users will have roles:
    regular
    |
    manager
    |
    globalManager
    And different roles will have different capabilities, e.g., globalManager can create users, but regular users cannot. I’m still not sure how I can approach this. I’m thinking to use Cognito User Pool, and attach users to IAM User Groups, and make the relevant API’s require appropriate role. How else can I achieve Role Based Access Control model do you think?
    c
    f
    • 3
    • 3
  • g

    Gerald

    11/06/2021, 3:48 PM
    Why sst automatically create a dynamo table? how can I disable it?
    ö
    r
    f
    • 4
    • 4
  • g

    Gerald

    11/06/2021, 5:28 PM
    How to fix this?
    Do not set the "env" prop while initializing "MyStack" stack. Use the "AWS_PROFILE" environment variable and "--region" CLI option instead.
    I am just passing an env just like this
    new MyStack(app, 'MyStack', {
    env: {
    account: '123456789012',
    region: 'us-east-1'
    },
    });
    r
    • 2
    • 3
  • g

    Gerald

    11/06/2021, 5:45 PM
    I am just adding route53 record for the custom domain of my user pool
    new route53.ARecord(this, "CustomerUserPoolDomainARecord", {
    zone: _props_?.hostedZone!,
    recordName: domainName,
    target: route53.RecordTarget.fromAlias(
    new route53Targets.UserPoolDomainTarget(userPoolDomain)
    ),
    });
    What does this error means?
    Error: Cannot find asset at /Users/gbc9720/Documents/projects/food_delivery_backend/.build/lib/runtime
    at new AssetStaging (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/core/lib/asset-staging.ts:113:13)
    at new Asset (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:68:21)
    at AssetCode.bind (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-lambda/lib/code.ts:183:20)
    at new Function2 (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-lambda/lib/function.ts:335:29)
    at SingletonFunction.ensureLambda (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:93:12)
    at new SingletonFunction (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:32:32)
    at new AwsCustomResource (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:194:22)
    at UserPoolDomain.get cloudFrontDomainName [as cloudFrontDomainName] (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-cognito/lib/user-pool-domain.ts:98:39)
    at UserPoolDomainTarget.bind (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-route53-targets/lib/userpool-domain.ts:12:28)
    at new RecordSet (/Users/gbc9720/Documents/projects/food_delivery_backend/node_modules/@aws-cdk/aws-route53/lib/record-set.ts:124:73)
    r
    f
    • 3
    • 16
  • d

    Devin

    11/06/2021, 6:59 PM
    if i run
    Copy code
    npx create-serverless-stack@latest my-cool-app
    then cd into the repo and run npm run
    Copy code
    npm run test
    I get ✅ If I then run
    Copy code
    npx create-react-app frontend --use-npm
    per the docs and then run
    Copy code
    npm run test
    the tests fail. The error is similar to
    Copy code
    > .../my-new-app/frontend/src/App.test.js:5:9: error: Unexpected "<"
        5 │   render(<App />);
          ╵          ^
    
     FAIL  frontend/src/App.test.js
      ● Test suite failed to run
    
        Transform failed with 1 error:
        .../my-new-app/frontend/src/App.test.js:5:9: error: Unexpected "<"
    What is a proper way to set up an app so I can not have this probelm
    f
    t
    • 3
    • 7
  • j

    Justin Philpott

    11/06/2021, 8:44 PM
    I just followed the NextJS demo tutorial to the letter - the live Lambda part worked fine then deployment to prod seemed ok, but on clicking the "Click Me" I got the lovely inline error: 503 Error, The lambda function associated with the Cloudfront distrib is invalid or doesn't have the required permissions.... this isn't inspiring much confidence for a first go I gotta say!
    d
    r
    f
    • 4
    • 14
  • d

    Devin

    11/06/2021, 9:35 PM
    I was thinking about building something like this
    Copy code
    myCoolApp
      /stacks
      /frontend - a react app 
      /website - a gatsby site
    I’d then have my app deploy at
    Copy code
    <http://app.myCoolApp.com|app.myCoolApp.com> //react site
    <http://www.myCoolApp.com|www.myCoolApp.com> //gatsby
    <http://myCoolApp.com|myCoolApp.com> // gatsby
    Or something. Really I just want to avoid Next but have some static content for SEO. Any ideas?
    j
    • 2
    • 11
  • ö

    Ömer Toraman

    11/06/2021, 10:17 PM
    For configuring Cognito, which one should be used? 1.
    Copy code
    new Auth(this, "Auth", {
      cognito: { signInAliases: { email: true } },
    });
    2.
    Copy code
    new Auth(this, "Auth", {
      cognito: {
        userPool: {
          signInAliases: { email: true, phone: true },
        },
      },
    });
    There are examples for both of them in the documentation. The upgrading to v0.12.0 section ( https://docs.serverless-stack.com/constructs/Auth#upgrading-to-v0120 ) suggests to use the second one, but I’m not sure what that version corresponds to.
    a
    j
    f
    • 4
    • 17
1...293031...83Latest