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

    Nicklas Christiansen

    03/07/2022, 9:11 PM
    Hi Guys New to sst. I created a second dynamodb table called "Events" and am trying to write data to it from a newly created frontend page, but for some reason it keeps trying to write to the other table "Notes". I followed the guide from Serverless-Stack. How do I specify which table should be written to? I call this from the frontend page:
    Copy code
    function createEvent(content) {
        return <http://API.post|API.post>("notes", "/events", {
            body: content
        });
        
      }
    I tried to add this to routes in ApiStack.js:
    Copy code
    "POST /events": "src/createEvent.main",
    With this createEvent:
    Copy code
    import * as uuid from "uuid";
    import handler from "./util/handler";
    import dynamoDb from "./util/dynamodb";
    
    export const main = handler(async (event) => {
      const data = JSON.parse(event.body);
      const params = {
        TableName: process.env.TABLE_NAME,
        Item: {
          // The attributes of the item to be created
          eventId: uuid.v1(), // A unique uuid
          name: data.content, // Parsed from request body
          max_players: data.max_players,
          createdAt: Date.now(), // Current Unix timestamp
        },
      };
    
      await dynamoDb.put(params);
    
      return params.Item;
    });
    Added this to StorageStack.js:
    Copy code
    this.table2 = new sst.Table(this, "Events", {
      fields: {
    
        eventId: sst.TableFieldType.STRING,
    
      },
    
      primaryIndex: { partitionKey: "eventId" },
    
    });
    • 1
    • 1
  • h

    Hans Song

    03/08/2022, 12:34 AM
    hey guys, i have 2 questions • how would we go about specifying a bootstrap stack? would
    sst cdk deploy --toolkit-stack-name mystackname
    work as expected? • is there any way for lambas running in the sst runtime to have their output logged to stdout/stderr as well?
    a
    f
    • 3
    • 27
  • r

    Ross Gerbasi

    03/08/2022, 1:18 AM
    Hey @thdxr I notice after upgrading to 0.67.0 we lost jest, ts-jest and babel from the dependencies. So when i run
    npm run test
    it can't find jest. Is this expected? If so do we need to install jest and configure TS for it ourselves now?
    t
    r
    • 3
    • 70
  • m

    Michael James Munar

    03/08/2022, 2:44 AM
    Hi, has anybody set up a customDomain using Digital Ocean?
    Copy code
    customDomain: {
            domainName: '<http://customDomain.com|customDomain.com>',
            isExternalDomain: true,
            certificate: Certificate.fromCertificateArn(this, 'Digital Ocean Certificate', certificate-arn),
          }
    I have also tried to configure custom domain in API Gateway and hosted zone in route 53, but nothing seems to work
    f
    l
    • 3
    • 12
  • f

    Fazi

    03/08/2022, 2:07 PM
    Hi, I have suddenly started getting the following message:
    Copy code
    TypeError: Cannot read properties of undefined (reading 'logs')
        at /Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/cli/scripts/start.js:176:13
        at recipe (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/core/dist/local/server.js:76:17)
        at Immer.produce (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/immer/src/core/immerClass.ts:94:14)
        at Immer.produceWithPatches (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/immer/src/core/immerClass.ts:141:23)
        at updateState (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/core/dist/local/server.js:48:64)
        at Object.updateFunction (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/core/dist/local/server.js:65:20)
        at /Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/cli/scripts/start.js:174:11
        at EventDelegate.trigger (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/core/dist/runtime/server.js:29:13)
        at Socket.<anonymous> (/Users/user/Desktop/services-python-app-integration/app_integration/node_modules/@serverless-stack/core/dist/runtime/server.js:233:31)
        at Socket.emit (node:events:527:28)
    Any idea what could be causing this? Dependencies:
    Copy code
    "@serverless-stack/cli": "0.67.2",
    "@serverless-stack/resources": "0.67.2",
    "aws-cdk-lib": "2.15.0",
    "@tsconfig/node14": "^1.0.1",
    "@types/aws-lambda": "^8.10.93",
    "@types/node": "^17.0.21"
    t
    m
    +2
    • 5
    • 25
  • l

    Luca Carangella

    03/08/2022, 3:40 PM
    Has anyone seen this before?
    f
    • 2
    • 1
  • l

    Luca Carangella

    03/08/2022, 3:53 PM
    When I follow this tutorial: https://serverless-stack.com/examples/how-to-add-jwt-authorization-with-auth0-to-a-serverless-api.html I get an error when I deploy: Error: AuthorizerPayloadFormatVersion can only be set for REQUEST authorizer. (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 1681e47c-afaf-44ba-a7e2-03dff57cb202; Proxy: null)
    f
    • 2
    • 2
  • t

    thdxr

    03/08/2022, 4:08 PM
    hey we need to see how you're using these as well
    s
    • 2
    • 3
  • t

    Thomas Ankcorn

    03/08/2022, 4:11 PM
    you need to return handleSuccess() and handleError()
    s
    • 2
    • 1
  • m

    Maged Mortaga

    03/08/2022, 4:11 PM
    You have to return the result of
    handleSuccess
    /
    handleError
    s
    • 2
    • 1
  • j

    Jeff Hanna

    03/08/2022, 5:30 PM
    hey guys! hoping someone can help point me to the right guide to learn the fundamentals of SST I’ve inherited a stack from another developer who built it on SST my previous (limited) AWS IaC experience was with AWS SAM / CloudFormation I’m loving CDK and your product seems like an amazing enhancement of CDK 🙏 but I feel like I need stronger fundamentals before continuing and I’m confused by which of the guides is the right place to start
    s
    • 2
    • 3
  • j

    Jan Plaček

    03/08/2022, 6:20 PM
    Would it be feasible and reasonable to generalize the StaticSite handling of env vars, so they could be accessed in any kind of local script (not just site)? Let's say I would like to have a devel script that creates few test users in cognito pool. It needs to know the pool id, so I would run the script with
    sst-evn
    Or is it already possible?
    t
    f
    • 3
    • 55
  • j

    Jeff Hanna

    03/08/2022, 6:52 PM
    @Seth Geoghegan are there any guides on dependencies between stacks and behavior when there are failures? my app has several stacks: Api, Auth, DB, etc. when I deploy a new “copy” of my stack (e.g. dev/staging/prod) I have to deploy 10 times to get it to work, each time one more stack succeeds then the last time until all succeed I suspect this is because the stack are dependent on each other but my CloudFormation doesn’t have the dependencies mapped properly so it doesn’t get the order of operations right but this also concerns me because with CloudFormation my deployments were all or no successful and rolled back to successful state if anything went wrong. Now I’m afraid I”m getting into partial deployment states where things will be broken
    s
    f
    • 3
    • 10
  • r

    Ross Coundon

    03/08/2022, 9:18 PM
    I’m getting a bucket x already exists error when deploying a stack to a new stage. The buckets are created based on an environment variable, basically a comma-separated list of countries. The creation function looks like this:
    Copy code
    createPortfolioDataBuckets(removalPolicy: RemovalPolicy, countries: string[]): EnvVarBucketMap {
        const envVarBucketMap: EnvVarBucketMap = {};
        for (const country of countries) {
          const bucket = new sst.Bucket(this, `${this.stage}-${country}-portfolio-data`, {
            s3Bucket: {
              removalPolicy,
              accessControl: BucketAccessControl.PRIVATE,
              blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
              versioned: true,
              bucketName: `${this.stage}-${country}-portfolio-data`,
            },
          });
          bucket.s3Bucket.addCorsRule(corsBucketRule);
          const envVarName = `${country.toUpperCase()}_PORTFOLIO_BUCKET`;
          envVarBucketMap[envVarName] = bucket;
        }
        return envVarBucketMap;
      }
    This function is called only once in the stack, the value of the string array that’s passed in is
    ['germany', 'italy']
    so the bucket names and IDs should be unique. Can anyone see what could be causing the issue?
    t
    • 2
    • 7
  • j

    Jeff Hanna

    03/08/2022, 9:44 PM
    hey guys, huge thanks for all the help so far 🙌 Now I’m trying to restore my serverless aurora cluster from a snapshot as a pre-launch exercise to make sure we can recover from a disaster I see that CDK has a construct for this in 1.147.0 First Question: SST does not support 1.147.0 yet right? I think I was able to workaround this with an escape hatch, but my deployment is complaining that the cluster can’t be updated because it is in use. Second Question: Anyone familiar with this and know how to restore a cluster?
    Copy code
    uat-polls-api-Database failed: Export uat-polls-api-Database:ExportsOutputRefDatabaseB269D8BB88F4B1C4 cannot be updated as it is in use by uat-polls-api-Api, uat-polls-api-Auth and uat-polls-api-Migrate
    FYI under the hood restoring actually creates a new serverless cluster from the snapshot
    f
    m
    • 3
    • 23
  • m

    matt resnik

    03/08/2022, 10:46 PM
    for live lambda refresh to work, do the files have to live in the same directory as sst? I've got it a level up from there.. and it doesn't seem to be picking up changes
    t
    • 2
    • 9
  • m

    Michael James Munar

    03/09/2022, 12:14 PM
    Hey guys, this question goes to those who have deployed their apps and functions to production. https://docs.serverless-stack.com/advanced/monitoring I saw the monitoring solutions here and would like to know which solutions do you use and why?
    m
    r
    f
    • 4
    • 5
  • s

    Shadab

    03/09/2022, 12:21 PM
    I followed this repo and was able to setup an Apollo GraphQL API. Now I want to use RDS postgrace with it, Is there any example repo for it? All existing examples uses REST
    f
    • 2
    • 11
  • s

    Sulaiman Baig

    03/09/2022, 2:28 PM
    I tested every endpoint in debug mode by running command npx sst start. It was ok. Then I tried to deploy and ran this command npx sst deploy --stage prod. I got an internal server error in postman response when I hit prod endpoints. After that I again ran npx sst start to test what is going wrong then I got this message in console cf943986-7019-494c-b35d-ffb1d57ee0a0 RESPONSE {"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{\"data\":{\"_id\":\"86b5b4f8-78fb-4a0d-b753-51d4e4e59c10\",\"email\":\"email\",\"username\":\"username\",\"address... 552 more characters"} cf943986-7019-494c-b35d-ffb1d57ee0a0-1646835997352 Failed to send response because the Lambda function is disconnected Please guide me what I am doing wrong?
    • 1
    • 1
  • s

    Sulaiman Baig

    03/09/2022, 3:33 PM
    I restarted my laptop and ran npx sst start again. now working fine but I observed one thing. this error was related to time response. if response time is big then it will throw an error otherwise no error. I am showing time responses in images. I got some errors with big-time responses. an an error wthe as same as follows Failed to send response because the Lambda function is disconnected
    f
    • 2
    • 4
  • r

    Ross Gerbasi

    03/09/2022, 8:23 PM
    Does
    sst deploy
    read from
    env
    files early enough to set a profile? Just checking out the docs here, https://docs.serverless-stack.com/packages/cli#aws-profile realizing I would like to swap profiles. If I have a
    AWS_PROFILE
    in my
    .env
    or
    .env.production
    will that get picked up or does it need to get set prior to running the command
    AWS_PROFILE=production npx sst deploy
    t
    • 2
    • 16
  • j

    Jeff Hanna

    03/09/2022, 10:13 PM
    hey guys, I’m getting an error that only shows when I am NOT live debugging I made a change to my auth trigger lambda to update my DB during sign in when I live debug it works perfectly, the DB is updated and a token is given to the client however when I deploy and test again, the DB query hangs and the lambda times out after 10s any ideas? thanks so much for your help! 🙏
    t
    s
    f
    • 4
    • 36
  • j

    Jeff Hanna

    03/09/2022, 11:21 PM
    ah I see that I could setDefaultFunctionProps but I don’t think bundle would be merged with the functions direct bundle props
    f
    • 2
    • 2
  • d

    David Rollins

    03/10/2022, 12:58 AM
    This is my first post here - really loving this framework. I have a Cognito protected endpoint - I also have thumbnails I pop into an S3 bucket and I only want authenticated users to be able to reference those thumbnails - I display them in a list UX - but I do not want any one who grabs the url to these things to be able to down load them unless they are authenticated. The thumbnails are of architecture diagrams so they are not something I want made public. My current set up is the thumbnails are in an s3 read public bucket and I reference the public url of the objects in my code - but those links are really public which I do not want. It works but the image urls are not protected. How should I go about protecting these image urls?
    k
    f
    • 3
    • 10
  • t

    Tonny (sstNerd)

    03/10/2022, 5:06 AM
    Hey SST community, I’ve a random question for those who are really experimented into real serverless applications: do you have a way to lock your application if you ever get slammed? (by either some sort of DDOS or “bots” (apparent real-traffic that is not real but is just killing your AWS budget)? I want to sell SST as a solution in the company I work on but that is my only (and stronger) downside here b/c I’ve no way to guarantee that the billings here are going to stick to our budget as in a traditional cloud. Any input/experience you can share about that?
    o
    t
    +2
    • 5
    • 13
  • s

    Sulaiman Baig

    03/10/2022, 5:27 AM
    Successfully built and deployed the app on AWS but getting { "message": "Internal Server Error" } in the postman when I am hitting any URL How can I see logs and errors in AWS deplyed app
    s
    f
    • 3
    • 4
  • b

    Brinsley

    03/10/2022, 7:17 AM
    Hey guys, I’m back with some more RDS problems, yay! I’ve moved my implementation over to use the new SST RDS construct and I was fine running start and deploy commands for a while, but now I’m getting an error in the SST code around the migration function - weird thing is that I was always specifying the
    migrations
    param so no idea why it suddenly started blowing up. Any ideas on this?
    Copy code
    TypeError: Cannot read property 'secretArn' of undefined
        at RDS.createMigrationsFunction (/Users/me/Git/repo/node_modules/@serverless-stack/resources/src/RDS.ts:287:55)
        at new RDS (/Users/me/Git/repo/node_modules/@serverless-stack/resources/src/RDS.ts:130:36)
        at new ApiStack (/Users/me/Git/repo/stacks/ApiStack.ts:77:20)
        at Object.main (/Users/me/Git/repo/stacks/index.ts:35:5)
        at Object.<anonymous> (/Users/me/Git/repo/.build/run.js:94:16)
        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 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    f
    • 2
    • 13
  • j

    Jan Plaček

    03/10/2022, 10:08 AM
    Today, I was presenting SST to my colleagues and I absolutely don't have a clue why, but the change detection suddenly doesn't work for any existing function. If I add new function, it works, watcher pickups changes. When I restart
    sst start
    it works no longer even for the previously added function. EDIT: It does not work to anyone of us, it doesn't seem to be a local issue. I use both explicit Function creation and the ones scaffolded by SST from function props, neither works. EDIT 2: Found out what's wrong. The changes are picked up correctly (based on
    sst-debug.log
    ), but it won't rebuild/reload the function unless you hit the endpoint with a request at least once. Is this by design?
    t
    • 2
    • 15
  • b

    Brinsley

    03/10/2022, 10:17 AM
    Hey guys, think this one will be for @Frank and @thdxr, think I’m super close to getting this RDS thing licked but looks like my migrations didn’t run on deployment (I’m doing an actual deploy, not a
    start
    ). Got the following error in CloudWatch:
    Copy code
    ERROR	[Error: EROFS: read-only file system, copyfile '/var/task/sst_rds_migration_scripts/000001_create_tables.js' -> '/var/task/sst_rds_migration_scripts/000001_create_tables.js1646905935564.js'] {
      errno: -30,
      code: 'EROFS',
      syscall: 'copyfile',
      path: '/var/task/sst_rds_migration_scripts/000001_create_tables.js',
      dest: '/var/task/sst_rds_migration_scripts/000001_create_tables.js1646905935564.js'
    }
    Currently Googling, any ideas?
    t
    j
    +2
    • 5
    • 12
  • m

    Mischa Spiegelmock

    03/10/2022, 11:49 AM
    I'm stuck in a horrible mess.. I have a few stacks in my app. Stack B depends on stack A for a secret which is exported, and I can't delete it because it says "Secrets Manager can't find the specified secret" (the secret exists, I don't know why it says this. I checked the references in the template and the secret and secret values exist that it refers to). I can't delete stack A because it says "Export test-ExportsOutputRefSecretsAppSecretsE2C09E50831EF5BE cannot be deleted as it is in use by test-Service ... (and 8 more)" I just want to delete my stacks but can't even do that. Any suggestions for how to nuke them?
    t
    f
    • 3
    • 10
1...565758...83Latest