cdk-nextjs
Version:
Deploy Next.js apps on AWS with CDK
55 lines (54 loc) • 2.29 kB
TypeScript
import { IVpc } from "aws-cdk-lib/aws-ec2";
import { Construct } from "constructs";
import { NextjsType } from "./constants";
import { OptionalVpcProps } from "./generated-structs/OptionalVpcProps";
export interface NextjsVpcOverrides {
readonly vpcProps?: OptionalVpcProps;
}
export interface NextjsVpcProps {
readonly nextjsType: NextjsType;
/**
* Override any construct.
*/
readonly overrides?: NextjsVpcOverrides;
/**
* Bring your own VPC.
*/
readonly vpc?: IVpc;
}
/**
* cdk-nextjs requires a VPC because of the use of EFS but if you're building on
* AWS you probably already need one for other resources (i.e. RDS/Aurora).
* You can provide your own VPC via `overrides.nextjsVpc.vpc` but you'll be
* responsible for creating the VPC. All cdk-nextjs constructs require a
* `SubnetType.PRIVATE_ISOLATED` subnet for EFS and `SubnetType.PRIVATE_WITH_EGRESS`
* for compute. `NextjsRegionalContainers` requires a `SubnetType.PUBLIC`
* subnet for CloudFront to reach the ALB. `NextjsGlobalFunctions` and
* `NextjsGlobalContainers` don't require a `SubnetType.PUBLIC` subnet because
* CloudFront accesses their compute securely through Function URL and VPC
* Origin Access.
*
* Note, if you use `NextjsVpc` then the default CDK VPC will be created
* for you with 2 AZs of all 3 types of subnets with a NAT Gateway in your
* `SubnetType.PUBLIC` subnet to allow for secure internet access from your
* `SubnetType.PRIVATE_WITH_EGRESS` subnet. This is recommended by AWS, but
* it costs $65/month for 2 AZs. See examples/low-cost for alternative.
*
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#subnet-types
*/
export declare class NextjsVpc extends Construct {
vpc: IVpc;
private props;
constructor(scope: Construct, id: string, props: NextjsVpcProps);
private createVpc;
/**
* Best practice is to use VPC endpoints between VPC and serverless resources
* so that traffic does not go over public internet.
*
* While gateway endpoints are free, interface endpoints (use PrivateLink)
* cost ~$7/month/az.
*
* @see https://www.alexdebrie.com/posts/aws-lambda-vpc/#set-up-a-vpc-endpoint-for-your-aws-service
*/
private createVpcEndpoints;
}