sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use the CDK

coltenkrauter opened this issue · comments

Would you be willing to provide usage instructions for importing and using the CDK constructs that you've made here so I can easily import them and add them to my own CDK code?

Context

I have other infra that I deploy to AWS (databases, APIs) and I'd want to deploy a NextJS app to Lambda as well.

Additional thoughts

I would like if there was a construct, say NextJSLambda, that I could import and deploy in my own stack similar to this.

import { NextJSLambda } from 'sladg/nextjs-lambda';

interface MyNextJSStack {
  config: Config;
  zoneId: string;
}

export class MyNextJSStack extends Construct {
  readonly nextJSApp;
  constructor(scope: Construct, id: string, props: MyNextJSStackProps) {
    super(scope, id);

    // Next
    this.nextJSApp = new NextJSLambda(this, `${id}Lambda`, {
      description: `${id} infra created by NextJSLambda construct`,
      runtime: Runtime.NODEJS_16_X,
      memory: 1024,
      timeout: Duration.seconds(30),
      withLogging: true,
      name: {
        apiLambda: `${id}Api`,
        imageLambda: `${id}Image`,
      },
      domain: {
        certificate,
        domainNames: [props.config.domainName],
        hostedZone: zone,
      },
      s3Props: {
        bucketName: `${props.config.prefixKebabCase}next-bucket`,
      },
    });
  }
}

What do you think?

commented

Hey! Check out version 5.2.0 and corresponding documentation here: https://github.com/sladg/nextjs-lambda/blob/master/docs/CDK.md

I have exported all internal functions to allow for more granular control over using whole Stack. Also, Stack's resources are now available (no longer private).

commented

Closing as documentation is part of repo.
Feel free to reopen/create new issue for specific problems