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

    Sam Hulick

    08/12/2021, 3:08 AM
    anyone know if it’s possible in CDK to reference a Lambda layer that’s already deployed (outside of the infra code).. especially one in another AWS account
    g
    a
    j
    • 4
    • 102
  • s

    Sam Hulick

    08/12/2021, 6:00 AM
    just leaving this here before I actually go to bed.. I’m having trouble granting a Lambda func permissions to two buckets:
    Copy code
    transcodeFunction.attachPermissions([
        [props!.uploadBucket, 'grantRead'],
        [props!.storageBucket, 'grantWrite'],
      ]);
    when I deploy, I get this:
    Copy code
    TypeError: construct[methodName] is not a function
    f
    t
    • 3
    • 4
  • s

    Sam Hulick

    08/12/2021, 6:23 AM
    how do I test Lambda functions using
    yarn start
    if they’re not part of an API? 🤔 say I have 5 functions that are part of a step function, and I want to just test one of those in isolation. in Serverless Framework, I could just use
    sls invoke local -f
    to do this.
    k
    f
    • 3
    • 13
  • b

    Bhuvaneshwaran Rajendran

    08/12/2021, 8:33 AM
    How do I get the current stage value inside the lambda function? i.e local, stage, prod and etc..
    f
    • 2
    • 2
  • f

    Fazi

    08/12/2021, 2:18 PM
    Hi, I am deploying my stack to production. However, viewing the cloudwatch logs, I get the following issue:
    Copy code
    [ERROR] Runtime.ImportModuleError: Unable to import module 'index': No module named 'src' Traceback (most recent call last):
    
    2021-08-12T15:06:09.638+01:00
    My function definition is as follows:
    Copy code
    const skillsSyncFunction = new Function(this, 'SkillsSyncFunction', {
          srcPath: "src/lambdas/skills_sync",
          handler: 'index.handler',
          timeout: 30,
          environment: env,
          permissions: ["ssm", skillsTable, bulkAssignOrchestratorTopic],
          description: "Blah Blah"
        });
    Folder structure:
    MyApp/src/lambdas/skills_sync/index.py
    Everything works locally in the
    Debug_Stack
    I should add
    t
    f
    • 3
    • 27
  • s

    Sam Hulick

    08/12/2021, 3:51 PM
    morning, you fine folks! quick/easy question about monorepos + yarn workspaces. say I have 4 services in
    src/services
    , and 2 of them need the same npm dependency. should I run
    yarn add somepkg
    at the root level, or just do
    yarn workspace service1 add somepkg && yarn workspace service2 add somepkg
    ? in other words, are root level dependencies intended to be shared among workspaces/services.. or should it be reserved only for things pertaining to the SST stack code?
    a
    t
    • 3
    • 9
  • b

    brent

    08/12/2021, 4:00 PM
    Hey all, getting a bit of an error running the
    start
    command. Was working fine up until this morning. I start up and then I get a websocket connection error that just infinitely repeats. I don't really think I changed very much that would have affected this. Look familiar to anyone, or anyone know where I might be able to start looking? https://gist.github.com/mittonface/28080899524db2978e567e7aaefa4995
    g
    • 2
    • 4
  • g

    Gabriel Bleu

    08/12/2021, 4:14 PM
    Hello, does anyone successfully ran the tests on serverless-stack/lerna-yarn-starter ?
    t
    • 2
    • 6
  • g

    Garret Harp

    08/12/2021, 7:03 PM
    Having some issues with the websocket api not entirely sure what I am doing wrong. In my stack I have:
    Copy code
    new WebSocketApi(this, 'WebSocketApi', {
    	routes: {
    		$connect: 'src/functions/actions/websocket/connect.handler'
    	}
    })
    And the lambda code is:
    Copy code
    export const handler = (event: unknown) => {
    	console.log(event)
    	return {
    		statusCode: 200,
    		body: 'test'
    	}
    }
    It logs the event just fine, but every websocket just immediately disconnects.
    t
    • 2
    • 4
  • g

    Garret Harp

    08/12/2021, 8:05 PM
    It looks like currently you cannot set the
    routeResponseSelectionExpression
    value for routes unless I am overlooking it, but it makes responding to websocket messages a lot easier. Without having that set you have to use the apigateway management api to respond whereas if I set it to
    $default
    whatever I put in the response body gets sent to the connection for me.
    t
    f
    • 3
    • 6
  • s

    Sam Hulick

    08/12/2021, 9:26 PM
    how do we avoid cyclic references in CDK/SST? for example, I set up Cognito in my “core” stack. later on, in my “media-processor” stack which depends on core, I need to add more permissions to authorized Cognito users:
    Copy code
    props!.cognitoAuth.attachPermissionsForAuthUsers([
          [uploadProcessorFunc, 'grantInvoke'],
        ]);
    This results in a cyclic dependency error.
    Copy code
    Error: 'dev-microservices-core' depends on 'dev-microservices-media-processor' (dev-microservices-core -> dev-microservices-media-processor/UploadProcFunc/Resource.Arn). Adding this dependency (dev-microservices-media-processor -> dev-microservices-core/UploadBucket/Bucket/Resource.Arn) would create a cyclic reference.
    f
    • 2
    • 13
  • s

    Sam Hulick

    08/12/2021, 9:51 PM
    is it safe to remove
    "declaration": true,
    from tsconfig? it was causing me some headaches
    t
    • 2
    • 33
  • s

    Sam Hulick

    08/13/2021, 5:12 AM
    does
    .build/
    always contain the most recent set of
    .js
    and
    .js.map
    files after a build or deploy? in other words, is that a reliable place to have sentry-cli grab source & source maps from to upload to Sentry?
    f
    • 2
    • 3
  • p

    Pavan Kumar

    08/13/2021, 11:44 AM
    What is the workflow when multiple developer are working with SST. Do each developer need separate AWS account, or they can use same AWS account with different IAM user.
    t
    f
    • 3
    • 8
  • f

    Fazi

    08/13/2021, 1:22 PM
    Hi all, Is it expected behaviour when running
    npx sst remove
    to get the following message:
    Copy code
    dev-sst-integration-layer-my-stack failed: dev-sst-integration-layer-UsersTable already exists
    I need to manually delete the dynamodb tables from AWS before running
    npx sst remove
    to ensure resource deletion.
    t
    f
    • 3
    • 5
  • s

    Sam Hulick

    08/13/2021, 4:47 PM
    potentially dumb question: do I have to run
    yarn deploy
    after stopping the
    yarn start
    process? any changes I’ve made during the debug process are already live anyway.. functions, at least. or does
    yarn deploy
    unhook the stubs & other magic needed to run stuff locally?
    t
    d
    • 3
    • 23
  • s

    Sam Hulick

    08/13/2021, 6:54 PM
    am I correct in thinking that
    stack.setDefaultFunctionProps()
    is the same thing as
    app.setDefaultFunctionProps()
    , except it only applies to functions created within that stack?
    t
    f
    • 3
    • 39
  • s

    Sam Hulick

    08/13/2021, 8:44 PM
    hey TypeScript savvy folks: how can I make it so both the infrastructure/stack code and my Lambda code stop yelling at me for using
    process.env.<some var>
    ? I always have to use the non-null assertion. I’d rather just declare everything so I know I won’t make any mistakes.. e.g.
    SENTRY_DSN: string;
    r
    t
    • 3
    • 23
  • s

    Sam Hulick

    08/13/2021, 10:33 PM
    just wanna bounce something off other devs (working solo on this stuff sucks, I miss water cooler days) 😄 say you have one SST project with a bunch of stacks. I’m thinking, does it make zero sense for Lambda functions to invoke other Lambda functions in the same or other stacks using
    lambda.invokeFunction
    ? seems like it’s a better idea to just
    import
    the function and call it directly. I can’t think of any reasons off the top of my head why this is a bad idea.. 🤔 or why it’s more advantageous to use
    lambda.invokeFunction
    t
    f
    • 3
    • 14
  • a

    Ashishkumar Pandey

    08/14/2021, 6:08 AM
    hey guys, how should I go about sharing a table construct across multiple stacks? Basically, I’ve an AppStack has my Table and then I’ve multiple Stacks which use Api constructs. I wan’t to addPermissions to the previously created Table in all these Apis.
    f
    • 2
    • 3
  • s

    Sam Hulick

    08/15/2021, 12:42 AM
    I noticed
    .map
    files are being included when uploading code to Lambda. is there a way to prevent this, since I’ll (eventually) be uploading those to Sentry instead?
    t
    f
    j
    • 4
    • 5
  • p

    Patrick Young

    08/15/2021, 2:22 AM
    I have a core stack thats in its own "repo" (using monorepo rush.js ftw!). Core consists of VPC / Cognito User pool which allows me to control env (dev / sandbox / test / prod / whatever). I want to setup our BFF to us that userpool and create its own identity pool etc. (pretty sure this is a thing). Main goal is that every sandbox / dev / whatever doesn't have to kick up its own VPC / Cognito Pool / Maybe like redshift or something... unclear what else I'm going to put into here.
    Copy code
    const userPoolId = cdk.Fn.importValue(`${props.infraCoreStage}-userpool-id`);
    const userPool = cognito.UserPool.fromUserPoolId(this, CONSTANTS.environmentUserPool, userPoolId);
    I can't seem to use the sst.Auth as userPool is a IUserPool.
    Copy code
    this.auth = new sst.Auth(this, scope.logicalPrefixedName(CONSTANTS.authPrefixName), {
                cognito: {
                    userPool, // does not like this
                    userPoolClient // or this
                },
                identityPool: {
                    allowUnauthenticatedIdentities: false
                },
                google: {
                    clientId
                }
            });
    1. Is this not a common pattern? 2. What horrible thing I'm I doing wrong? 3. I miss water cooler days too...
    s
    f
    • 3
    • 9
  • p

    Pavan Kumar

    08/15/2021, 4:26 AM
    I am trying to create rabbit my using following construct.
    Copy code
    const rabbitMQ = new CfnBroker(this, "name', {...});
    I want to get connection string out of created rabbitMQ. So I used following code.
    Copy code
    environment {
      RABBIT: rabbitMQ.attrAmqpEndpoints[0]
    }
    Even thought
    attrAmpqEndpoints
    is documented as
    string[]
    sst run stat
    was throwing error saying I can access array using index directly and I can access it using Fn.select(index, list). So I changed code to
    Copy code
    import { Fn } from '@aws-cdk/core';
    ...
    environment {
      RABBIT: Fn.select(0, rabbitMQ.attrAmqpEndpoints)
    }
    Above code worked, but, I don't understand why there is need to use
    Fn
    for accessing array element at index. While at typescript should be able to use
    list[0]
    right?
    s
    f
    • 3
    • 10
  • a

    Adrián Mouly

    08/15/2021, 9:27 PM
    Did somebody use this library to do authenticated HTTP calls to APIs hosted on AWS? https://github.com/mhart/aws4
    m
    • 2
    • 6
  • s

    Sam Hulick

    08/16/2021, 1:13 AM
    anyone know how to get the identity pool ID associated w/ a Cognito user pool? it’s needed for Amplify Auth
    m
    f
    • 3
    • 3
  • s

    Sam Hulick

    08/16/2021, 1:36 AM
    any reason the esbuild
    onEnd
    callback doesn’t work/exist in SST’s environment?
    { onResolve: [Function: onResolve], onLoad: [Function: onLoad] }
    t
    f
    • 3
    • 19
  • i

    Ilia Reingold

    08/16/2021, 3:02 AM
    Hey folks, I'm using a postConfirmation lamdbajs function, and it seems like when I deploy, imports/require statements don't work and cause an error. Code looks like this:
    Copy code
    /* eslint-disable no-console */
    const fetch = require('node-fetch');
    
    export async function main(event, context, callback) {
      try {
        // Post user data to elastic
    
        console.log('posting data to elastic...', process.env.API_URL);
    
        await fetch(
          `${process.env.API_URL}/users`, {
            method: 'POST',
            headers: {
              'content-type': 'application/json',
            },
            body: JSON.stringify(event),
          },
        )
          .then((res) => res.json()) // expecting a json response
          .then(() => callback(null, event));
      } catch (error) {
        console.log('there was an error', error);
        callback(null, event);
      }
    }
    It works fine when testing locally, but after running
    sst deploy
    and trying out the workflow, I noticed this in CloudWatch:
    Copy code
    2021-08-16T02:58:40.094Z	51cc72c5-0e44-4b15-8360-66170252a532	INFO	there was an error TypeError: fetch is not a function
        at Runtime.main [as handler] (/var/task/postConfirmation.js:1080:11)
        at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)
    So the one module I import is not working. It's definitely in my package.json:
    Copy code
    "dependencies": {
        "@aws-cdk/core": "1.111.0",
        "@serverless-stack/cli": "0.38.0",
        "@serverless-stack/resources": "0.38.0",
        "node-fetch": "^2.6.1"
      },
    Any thoughts?
    f
    • 2
    • 14
  • c

    Chad (cysense)

    08/16/2021, 6:30 AM
    Hey everyone, quick question. Does SST support env variables for auth or only the credentials file?
    f
    • 2
    • 2
  • s

    Sam Hulick

    08/17/2021, 1:00 AM
    just wanted to check something: this is the correct way to handle dependencies that are binaries, correct?
    Copy code
    bundle: {
          // sharp is a binary, and we have it in a Lambda layer, so exclude it
          externalModules: ['sharp'],
          loader: {
            '.node': 'binary',
          },
        },
    t
    • 2
    • 3
  • s

    Sam Hulick

    08/17/2021, 1:34 AM
    whoa! SST/CDK just tried to do something really messed up. I have a route that has a JWT authorizer. I modified it to be:
    Copy code
    'GET /media': {
        function: 'get-media.main',
        authorizationType: sst.ApiAuthorizationType.NONE,
      },
    so I can test the endpoint without needing authorization. SST said “Press ENTER to redeploy infrastructure” and then this happened:
    Copy code
    Deploying stacks
    Checking deploy status...
    dev-microservices-core | UPDATE_IN_PROGRESS | AWS::CloudFormation::Stack | dev-microservices-core
    dev-microservices-core | UPDATE_ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | dev-microservices-core Export dev-microservices-core:ExportsOutputRefUserPoolClient2F5918F753847A55 cannot be deleted as it is in use by dev-microservices-api
    Checking deploy status...
    Checking deploy status...
    dev-microservices-core | UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS | AWS::CloudFormation::Stack | dev-microservices-core
    dev-microservices-core | UPDATE_ROLLBACK_COMPLETE | AWS::CloudFormation::Stack | dev-microservices-core
    it tried to delete my Cognito user pool client??
    a
    t
    f
    • 4
    • 93
1...121314...83Latest