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

    Nicklas Nyegaard

    10/05/2021, 2:14 PM
    Hey I am seeing this error in cloudwatch when I deploy my API and lambda:
    [ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'src' Traceback (most recent call last):
    but when I run in debug mode I am able to hit the lambda
    d
    t
    f
    • 4
    • 65
  • j

    Josimar Zimermann

    10/05/2021, 2:38 PM
    After thinking a lot, I decided to architecting a solution using the multi repo concept. I reached that conclusion after reading this article: https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/ Some of the functions will need to share common code. To suite that, I'm thinking about Lambda layers. So, each layer would have its own repo. How can I test locally a function that uses a layer in another repo? If you have another approach or suggestion, I will appreciate to hear that.
    a
    t
    t
    • 4
    • 15
  • h

    Hubert

    10/05/2021, 2:43 PM
    Hello! I seem to be having 2 issues (that are probably unrelated to each other). 1. Websockets with CUSTOM authorizer throw an error.
    Copy code
    AuthorizerResultTtlInSeconds cannot be set for WEBSOCKET protocol Apis. (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 59e5ff5a-907f-4d2c-a2f6-0012888cf27d; Proxy: null)
    2. When running unit tests (
    sst test
    ), I seem to also be getting an error. I've tried to test my Websocket Authorizer and got inspiration from this: https://github.com/serverless-stack/serverless-stack/blob/e14edc65afa59493c615c59c5d520fda0e7b5477/packages/resources/test/WebSocketApi.test.ts#L617 Testing other areas of my stacks seem to also throw similar error or say that there's no resource like X at all.
    Copy code
    TypeError: Converting circular structure to JSON
            --> starting at object with constructor 'CloudAssembly'
            |     property 'artifacts' -> object with constructor 'Array'
            |     index 0 -> object with constructor 'TreeCloudArtifact'
            --- property 'assembly' closes the circle
            at JSON.stringify (<anonymous>)
    Thanks.
    f
    o
    • 3
    • 7
  • d

    Dan Van Brunt

    10/05/2021, 2:59 PM
    It appears manually deleting the
    stack
    and
    debug stack
    causes
    yarn start
    to fail with
    Copy code
    WebSocket connection error Error: getaddrinfo ENOTFOUND <http://NOTTELLING.execute-api.us-east-1.amazonaws.com|NOTTELLING.execute-api.us-east-1.amazonaws.com>
        at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) {
      errno: -3008,
      code: 'ENOTFOUND',
      syscall: 'getaddrinfo',
      hostname: '<http://NOTTELLING.execute-api.us-east-1.amazonaws.com|NOTTELLING.execute-api.us-east-1.amazonaws.com>'
    }
    Feels like this should instead either: • CLI Error out with debug stack not found • CLI detect debug stack missing and redeploy it In the mean time… is there a SST command to redeploy the debug stack?
    t
    f
    s
    • 4
    • 14
  • g

    Guy Shechter

    10/05/2021, 4:57 PM
    Sometimes we want to pull common dependencies to pass into a few of our stacks, e.g.
    route53.HostedZone.fromLookup
    and
    ec2.Vpc.fromLookup
    . We are doing this in a separate
    CommonDependenciesStack
    but it turns out that this creates an empty Cloudformation stack. Any other approach that we’re missing?
    t
    • 2
    • 2
  • g

    Guy Shechter

    10/05/2021, 6:40 PM
    We’ve been having a little bit of a problem with Cognito, where the deployer is looking for additional CDK files which are not being copied into the build directory. We are using CDK natively to create a user pool, client, and a custom auth domain with dns validated certificate and route53 A record. In order to make it work, we’ve had to manually sync some of these CDK resources into the build dir, ie,
    Copy code
    function syncCdkResourceLambdaPackages(buildDir: string) {
      const lambdaPackagesPath = path.resolve(process.cwd(), buildDir, 'lambda-packages');
      fs.mkdirSync(lambdaPackagesPath, { recursive: true });
      const awsCdkLambdaPackages = glob.sync("node_modules/@aws-cdk/**/lambda-packages");
      awsCdkLambdaPackages.forEach(packagePath => fs.copySync(packagePath, lambdaPackagesPath, { preserveTimestamps: true }))
    }
    
    function syncCdkCustomResourceRuntime(buildDir: string) {
      const runtimePath = path.resolve(process.cwd(), buildDir, 'lib', 'runtime');
      fs.mkdirSync(runtimePath, { recursive: true });
      const sdkApiMetadataPath = path.resolve(process.cwd(), buildDir, 'lib', 'sdk-api-metadata.json');
      fs.copySync("node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/runtime", runtimePath, { preserveTimestamps: true })
      fs.copyFileSync("node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/sdk-api-metadata.json", sdkApiMetadataPath)
    }
    Here’s one error trace:
    Copy code
    Error: Cannot find asset at demo_1/.build/lib/runtime
        at new AssetStaging (demo_1/node_modules/@aws-cdk/core/lib/asset-staging.ts:113:13)
        at new Asset (demo_1/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:68:21)
        at AssetCode.bind (demo_1/node_modules/@aws-cdk/aws-lambda/lib/code.ts:183:20)
        at new Function3 (demo_1/node_modules/@aws-cdk/aws-lambda/lib/function.ts:331:29)
        at SingletonFunction.ensureLambda (demo_1/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:93:12)
        at new SingletonFunction (demo_1/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:32:32)
        at new AwsCustomResource (demo_1/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:194:22)
        at UserPoolDomain.get cloudFrontDomainName [as cloudFrontDomainName] (demo_1/node_modules/@aws-cdk/aws-cognito/lib/user-pool-domain.ts:98:39)
        at UserPoolDomainTarget2.bind (demo_1/node_modules/@aws-cdk/aws-route53-targets/lib/userpool-domain.ts:12:28)
        at new RecordSet (demo_1/node_modules/@aws-cdk/aws-route53/lib/record-set.ts:124:73)
    t
    k
    • 3
    • 5
  • g

    Garret Harp

    10/05/2021, 7:28 PM
    Not sure if I am doing something wrong but it seems
    app.*setDefaultRemovalPolicy
    does not work. For dev stages I tell this to be destroy yet anytime I build it retains. (At least for s3 buckets and dynamo tables not sure about other items)*
    t
    • 2
    • 4
  • d

    Dan Van Brunt

    10/06/2021, 12:56 AM
    StaticSite
    build seems to be trying to use types? • CDK is in the root of the repo. • Frontend (Gatsby) is in
    ./frontend
    • I added this to
    tsconfig.json
    …
    "exclude": ["./jest.config.js", "./node_modules/**/*", "./build/**/*", "./frontend/**/*"],
    t
    • 2
    • 17
  • d

    David Chin

    10/06/2021, 2:42 AM
    (see attached screen capture) the seed.run site is having an issue fetching css from https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css suggest fetching from https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css instead ✌️ cc @Jay @Frank thanks!
    f
    j
    • 3
    • 8
  • t

    Tomasz Michalak

    10/06/2021, 10:34 AM
    Hi, I want to handle outbound traffic from my Lambda functions with some static IP. The solution I would like to use is a dedicated VPC with private subnet and NAT Gateway coupled with Elastic IP. From the AWS Console, I can easily create Lambda functions and assign them to the VPC and subnet (which I created earlier). I achieve the same using
    API
    and
    Function
    constructs. The use case: 1. Create VPC with all subnet configuration once. 2. Deploy all SST stacks (created per PR) to the same VPC, Lambdas should be deployed to the specific subnets.
    f
    • 2
    • 4
  • w

    Warwick Grigg

    10/06/2021, 2:16 PM
    I'm trying to get my head around the different treatment of environment variables in NextjsSite vs ReactStaticSite (and StaticSite). In my particular use case I want to reference other constructs in my SST app in my Nextjs source code (eg environment variables such as MY_OTHER_LAMBDA_API_URL and MY_CONTENT_BUCKET). With ReactStaticSite and StaticSite I can reference them, but not in NextjsSite. Just wondering why that is and whether it would be possible to make handling of NextjsSite source code more like ReactStaticSite and StaticSite? Or should I split my app into two different sst apps and somehow pass the outputs from one sst app into a sst NextJs app?
    f
    d
    +2
    • 5
    • 55
  • a

    Artem Kalantai

    10/06/2021, 3:23 PM
    maybe someone knows what’s going on, I’m using sst in production a half a year and I’m mostly satisfied, but today came new guy, we created new env for him, but when he is doing sst start from his machine he has this, from my machine it is ok, can understand what th……
    f
    • 2
    • 8
  • d

    Dan Van Brunt

    10/06/2021, 3:26 PM
    Having issues with StaticSite in regards to the env vars. • WORKS -
    yarn workspace frontend run build
    (gatsby build) • NO WORK -
    yarn deploy
    (SST)
    Copy code
    The site's gatsby-config.js failed validation:
    
    "siteMetadata.siteUrl" must be a valid uri
    Likely because we have a number of gatsby plugins that need the
    GATSBY_SITE_URL
    in order to work. Ex.
    gatsby-plugin-robots-txt
    , and
    siteMetadata
    all inside
    gatsby-config.js
    f
    t
    • 3
    • 105
  • b

    Bshr Ramadan

    10/06/2021, 5:09 PM
    Hello I have an apollo federation services, I am generating
    .graphql
    supergraph schema to use it in apollo gateway which is similar to this : https://www.apollographql.com/docs/federation/quickstart/#4-start-the-gateway the problem is when deploy to lambda, it is not deploying the
    .graphql
    file that I read it in gateway handler, and it throws error :
    no such file or directory, open 'schemas/gateway.graphql'"
    do you suggest a way to do this?
    f
    • 2
    • 3
  • s

    Sam Hulick

    10/06/2021, 5:18 PM
    I can no longer run
    yarn test
    . I get:
    Copy code
    Look like you're running sst for the first time in this directory. Please enter a stage name you'd like to use locally. Or hit enter to use the one based on your AWS credentials (samh):
    but if I run
    yarn test --stage dev
    (which usually fixes the above error), it says:
    Copy code
    ● Unrecognized CLI Parameter:
    
      Unrecognized option "stage".
    
      CLI Options Documentation:
      <https://jestjs.io/docs/en/cli.html>
    not sure how to get around this one
    f
    t
    • 3
    • 36
  • b

    brent

    10/06/2021, 6:59 PM
    Any reason that this code couldnt be easily extended to allow you to specify multiple alternate domain names? https://github.com/serverless-stack/serverless-stack/blob/b798c92bbccc47b6be0dccb8e3bfddf2fc6b6956/packages/resources/src/StaticSite.ts#L477-L484 i.e., Right now it will always produce an array with length == 1 so there doesn't seem to be away to have more than one alternate domain name on a cloudfront distribution
    f
    • 2
    • 3
  • m

    Mr.9715

    10/07/2021, 6:51 AM
    Hi guys, I am facing cross stack reference error. I have multiple http APIs behind a single cloudfront origin. now I am unable to update apig. here is the sequence. app -> cognito stack -> dynamo stack -> s3 stack -> 3x (api stack) -> cdn stack. I can clearly see that cdn stack is using import value from api stacks. any idea what could be the right way of resolving this?
    t
    m
    • 3
    • 9
  • a

    Alexandru-Bogdan Iaru

    10/07/2021, 3:16 PM
    Hi and thanks for the awesome project! 🙌 I got into a problem. My infrastructure folder & actual code folder are at the same level. Kind of like:
    Copy code
    | -- infrastructure | -- src
    |                   | -- package.json
    |
    | -- service ------ | -- src ------------- | -- functions -- | -- createProfileHandler.ts
    |                   | -- package.json
    When I try to build(current directory = infrastructure) , assets are built in the correct folder, but I get the "`Cannot find asset : somePath/service/src/functions/.build/---main-src-functions-createProfileHandler-handler-1633618636177`" error The function handler in the API props is "../service/src/functions/createProfileHandler.handler" I think the asset lookup is not looking for the right file because of the ".." in the path which is transformed to "--" in the asset filename. The strange thing is that sst start is deploying successfully and the error is encountered on sst build & sst deploy Can you give me some help on how to reference handlers from an outside folder(outside from infrastructure/lib folder)? I tried using: 1. srcPath & handler props 2. srcPath using setDefaultFunctionProps 3. only handler prop 4. with
    __dirname__
    Thanks!
    t
    n
    a
    • 4
    • 14
  • d

    Dan Van Brunt

    10/07/2021, 4:45 PM
    Questions about
    StaticSite
    • “when” are the production files copied to the s3 bucket? Is there differences between this answer when that command is
    yarn start
    vs
    yarn deploy
    ? • Sometimes it seems like there is only a dummy html content file in the bucket after a successful deploy, but why weren’t my frontend files copied up?
    t
    f
    • 3
    • 11
  • d

    Dan Van Brunt

    10/07/2021, 5:25 PM
    I think there is an issue with how the current
    fileOptions
    works in
    StaticSite
    since
    exclude
    and
    include
    are setup as static properties (where includes always override excludes) there is no way to reproduce this command that the s3 sync CLI could…
    Copy code
    aws s3 sync ./public/ "s3://${BUCKET_NAME}/" \
      --exclude "*" \
      --include "static/*" \
      --include "*.css" \
      --include "*.js" \
      --exclude "sw.js" \
      --cache-control 'public,max-age=31536000,immutable' --delete
    Notice the second
    exclude
    comes after a bunch of includes and another exclude. Perhaps laying out these fileOptions would have been better this way…
    Copy code
    {
      fileOptions: [
        {
          matching: [
            { exclude: '*' },
            { include: 'static/*' },
            { include: '*.css' },
            { include: '*.js' },
            { exclude: 'sw.js' },
          ],
          cacheControl: 'public,max-age=31536000,immutable',
        },
      ],
    }
    f
    • 2
    • 11
  • g

    Garret Harp

    10/07/2021, 6:09 PM
    Anyone happen to know if there are cdk constructs to create an algolia index? If not anyone have any guidance for how I might create one to do this for me if it is possible to do?
    t
    a
    +3
    • 6
    • 29
  • s

    Sam Hulick

    10/07/2021, 6:49 PM
    I’m having trouble running
    yarn test
    again 😕 it just hangs, and the node process starts eating up CPU
    a
    f
    • 3
    • 15
  • ö

    Ömer Toraman

    10/07/2021, 8:08 PM
    What is your opinion on modeling a request and marking set of rules on parameters so that it never hits your Lambda when the request is not valid to begin with? I see that your Lambdas will be called less, and that is good for pricing and throttling/concurrency. On the other hand, the Lambda pricing is very cheap, and if you dont have a heavy load it seems like you dont need it. I see the downside to this as that it will be more difficult to identify what part was invalid in the request. Because when it hits Lambda, you can log it to the CloudWatch. What do you think?
    r
    f
    • 3
    • 3
  • d

    Dan Van Brunt

    10/07/2021, 8:53 PM
    Is there a way to access
    app.stage
    from within a deeper nested construct? For example… if we wanted to access it from within
    StaticSite
    f
    • 2
    • 1
  • a

    Anatol

    10/07/2021, 10:17 PM
    Hello @Frank, For running my integration tests in seed.run, I need to run local mysql server. is it possible to install mysql on build server of seed.run and run? or can I use any favorite docker image for seed.run build server?
    f
    • 2
    • 2
  • s

    Sam Hulick

    10/08/2021, 5:00 PM
    did you guys see the notice from AWS this morning about the mistake in CDK regarding S3 bucket retention? seems like it might be a good idea to update to CDK 1.126.0
    t
    f
    • 3
    • 2
  • j

    Jonathan Chapman

    10/08/2021, 5:37 PM
    Are there any examples of multiple stacks in one repo?
    a
    t
    f
    • 4
    • 69
  • g

    Garret Harp

    10/08/2021, 5:53 PM
    Just curious if anyone knows how to do more complex type filters on event bus rules if possible. I use dynamodb streams to send item updates to eventbridge and want to create some rules that look at the dynamodb keys I send in the detail. This is an example of what the detail object would look like:
    Copy code
    Keys: {
      pk: "Charity#something",
      sk: "Charity#"
    },
    Record: { ...fullItem },
    Changes: [...whatKeysChanged]
    I want an eventbus rule to look at detail.Keys and make sure "pk" starts with "Charity#" and "sk" is equal to "Charity#" but not entirely sure how the eventPattern works for details.
    f
    • 2
    • 3
  • a

    Alexis Levasseur

    10/08/2021, 6:47 PM
    I've been using the 
    ReactStaticSite
     construct. It's been all good except right now, when I tried to deploy my site, sst does not upload to the s3 bucket. Seems like it's because it does not detect any changes.
    Stack desktop-dp-backend-site-stack
    Status: no changes
    Now, the stack itself hasn't changed, but the site I'm trying to deploy did. Is there any ways for sst to detect the build output from the site has indeed changed? Thanks in advance!
    t
    f
    • 3
    • 24
  • ö

    Ömer Toraman

    10/08/2021, 7:06 PM
    Hello there. I suppose most of you use more than a single AWS profile, and engage with cli tools that require one of the profiles. I would like to know how you manage to specify the AWS profile each time, because for me it sometimes requires an extra attention. I am using iTerm2 as the terminal app, and I use Visual Studio Code’s integrated terminal as well. The point I’m trying to make is that I dont keep working on the same terminal window (or better to say session) so that loading the profile as an environment variable just once is enough, but I have to do that every time I load a profile. How do you manage it?
    r
    • 2
    • 4
1...212223...83Latest