opennextcdk

package module
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

README

Typescript Java Go Python .NET
OpenNext CDK

Deploy NextJS on AWS using CDK IaC and OpenNext packaging

Contents

What is this?

A building block for Amazon's infrastructure-as-code CDK toolkit to deploy a NextJS app using AWS serverless services.

Your NextJS app is packaged using OpenNext to fit the serverless format on Lambda

Requirements

NextJs versions: >=12.3.0+ (includes 13.0.0+)

Platforms: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, win32-x64

Quickstart

NextJS setup

Add a dev dependency esbuild@0.17.16 to your NextJS project.

npm install --save-dev esbuild@0.17.16

CDK Construct

Use this construct in your CDK application to deploy your NextJS app to AWS.

Typescript Typescript NPM release

Install the dependency using npm:

npm install --save-dev esbuild@0.17.16 open-next-cdk

Use the construct in your CDK application:

import { Nextjs } from 'open-next-cdk';

new Nextjs(this, 'Web', {
  nextjsPath: './web', // relative path to nextjs project root
});
Java Java Maven Central release

Install the dependency using Maven:

<dependency>
  <groupId>io.dataspray</groupId>
  <artifactId>open-next-cdk</artifactId>
  <version>x.y.z</version>
</dependency>

Use the construct in your CDK application:

Nextjs.Builder.create(this, getConstructId())
        .nextjsPath("./web")
        .build();
Go Go Go release

Install the dependency:

go get github.com:datasprayio/open-next-cdk.git@go

Or checkout the code in the go branch.

Python Python Pypi release

Install the dependency:

pip install open-next-cdk
.NET .NET Nuget release

Install the dependency:

dotnet add package Dataspray.OpenNextCdk

This will automatically build your NextJS app and package it for you as part of the CDK construct.

If you would prefer to package it separately, see below:

Advanced

Pre-built OpenNext package

How-to

You may also provide already pre-built OpenNext package directly by building it yourself first:

open-next build

You will find a new folder .open-next which contains the packaging for your NextJS App. Now you can use the construct by instructing it not to build your app, just use the OpenNext folder directly:

import { Nextjs } from 'open-next-cdk';

new Nextjs(this, 'Web', {
  openNextPath: './web/.open-next', // relative path to .open-next folder
});

Additional security

How-to
import { RemovalPolicy, Stack } from "aws-cdk-lib";
import { Construct } from "constructs";
import { CfnWebAcl } from "aws-cdk-lib/aws-wafv2";
import { SecurityPolicyProtocol, type DistributionProps } from "aws-cdk-lib/aws-cloudfront";
import { Nextjs, type NextjsDistributionProps } from "cdk-nextjs-standalone";
import { Bucket, BlockPublicAccess, BucketEncryption } from "aws-cdk-lib/aws-s3";

// Because of `WebAcl`, this stack must be deployed in us-east-1. If you want
// to deploy Nextjs in another region, add WAF in separate stack deployed in us-east-1
export class UiStack {
  constructor(scope: Construct, id: string) {
    const webAcl = new CfnWebAcl(this, "WebAcl", { ... });
    new Nextjs(this, "NextSite", {
      nextjsPath: "...",
      defaults: {
        assetDeployment: {
          bucket: new Bucket(this, "NextjsAssetDeploymentBucket", {
            autoDeleteObjects: true,
            removalPolicy: RemovalPolicy.DESTROY,
            encryption: BucketEncryption.S3_MANAGED,
            enforceSSL: true,
            blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
          }),
        },
        distribution: {
          functionUrlAuthType: FunctionUrlAuthType.AWS_IAM,
          cdk: {
            distribution: {
              webAclId: webAcl.attrArn,
              minimumProtocolVersion: SecurityPolicyProtocol.TLS_V1_2_2021,
            } as DistributionProps,
          },
        } satisfies Partial<NextjsDistributionProps>,
      },
    });
  }
}

About

Deploys a NextJs static site with server-side rendering and API support. Uses AWS lambda and CloudFront.

There is a new (since Next 12) standalone output mode which uses output tracing to generate a minimal server and static files. This standalone server can be converted into a CloudFront distribution and a lambda handler that handles SSR, API, and routing.

The CloudFront default origin first checks S3 for static files and falls back to an HTTP origin using a lambda function URL.

Benefits

This approach is most compatible with new NextJs features such as ESM configuration, middleware, next-auth, and React server components ("appDir").

The unmaintained @serverless-nextjs project uses the deprecated serverless NextJs build target which prevents the use of new features. This construct was created to use the new standalone output build and newer AWS features like lambda function URLs and fallback origins.

You may want to look at Serverless Stack and its NextjsSite construct for an improved developer experience if you are building serverless applications on CDK.

Dependencies

Built on top of open-next, which was partially built using the original core of cdk-nextjs-standalone.

Similar projects

This project is heavily based on

Fork from cdk-nextjs

Compatible with: cdk-nextjs@3.2.1

This project has been initially forked from cdk-nextjs in order to publish the package to other langugages. So far notable changes are:

  • Extended language support: TS, Java, Go, .NET, Python.
  • Extended platform support: darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, win32-x64
  • Use pre-built open-next package

Contributing

Hey there, we value every new contribution a lot 🙏🏼 thank you. Open an issue or a PR and we'll gladly help you out.

Using Projen

Most boilerplate files are pre-generated including package.json. Don't update it directly, rather update .projenrc.js then run yarn projen to re-generate the files.

Documentation

Overview

Deploy a NextJS app using OpenNext packaging to serverless AWS using CDK

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageOptimizationLambda_ClassifyVersionProperty

func ImageOptimizationLambda_ClassifyVersionProperty(propertyName *string, locked *bool)

Record whether specific properties in the `AWS::Lambda::Function` resource should also be associated to the Version resource.

See 'currentVersion' section in the module README for more details.

func ImageOptimizationLambda_FromFunctionArn

func ImageOptimizationLambda_FromFunctionArn(scope constructs.Construct, id *string, functionArn *string) awslambda.IFunction

Import a lambda function into the CDK using its ARN.

func ImageOptimizationLambda_FromFunctionAttributes

func ImageOptimizationLambda_FromFunctionAttributes(scope constructs.Construct, id *string, attrs *awslambda.FunctionAttributes) awslambda.IFunction

Creates a Lambda function object which represents a function not defined within this stack.

func ImageOptimizationLambda_FromFunctionName

func ImageOptimizationLambda_FromFunctionName(scope constructs.Construct, id *string, functionName *string) awslambda.IFunction

Import a lambda function into the CDK using its name.

func ImageOptimizationLambda_IsConstruct

func ImageOptimizationLambda_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func ImageOptimizationLambda_IsOwnedResource

func ImageOptimizationLambda_IsOwnedResource(construct constructs.IConstruct) *bool

Returns true if the construct was created by CDK, and false otherwise.

func ImageOptimizationLambda_IsResource

func ImageOptimizationLambda_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource.

func ImageOptimizationLambda_MetricAll

func ImageOptimizationLambda_MetricAll(metricName *string, props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Return the given named metric for this Lambda.

func ImageOptimizationLambda_MetricAllConcurrentExecutions

func ImageOptimizationLambda_MetricAllConcurrentExecutions(props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Metric for the number of concurrent executions across all Lambdas. Default: max over 5 minutes.

func ImageOptimizationLambda_MetricAllDuration

func ImageOptimizationLambda_MetricAllDuration(props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Metric for the Duration executing all Lambdas. Default: average over 5 minutes.

func ImageOptimizationLambda_MetricAllErrors

func ImageOptimizationLambda_MetricAllErrors(props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Metric for the number of Errors executing all Lambdas. Default: sum over 5 minutes.

func ImageOptimizationLambda_MetricAllInvocations

func ImageOptimizationLambda_MetricAllInvocations(props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Metric for the number of invocations of all Lambdas. Default: sum over 5 minutes.

func ImageOptimizationLambda_MetricAllThrottles

func ImageOptimizationLambda_MetricAllThrottles(props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Metric for the number of throttled invocations of all Lambdas. Default: sum over 5 minutes.

func ImageOptimizationLambda_MetricAllUnreservedConcurrentExecutions

func ImageOptimizationLambda_MetricAllUnreservedConcurrentExecutions(props *awscloudwatch.MetricOptions) awscloudwatch.Metric

Metric for the number of unreserved concurrent executions across all Lambdas. Default: max over 5 minutes.

func NewImageOptimizationLambda_Override

func NewImageOptimizationLambda_Override(i ImageOptimizationLambda, scope constructs.Construct, id *string, props *ImageOptimizationProps)

func NewNextJsAssetsDeployment_Override

func NewNextJsAssetsDeployment_Override(n NextJsAssetsDeployment, scope constructs.Construct, id *string, props *NextjsAssetsDeploymentProps)

func NewNextJsLambda_Override

func NewNextJsLambda_Override(n NextJsLambda, scope constructs.Construct, id *string, props *NextjsLambdaProps)

func NewNextjsBuild_Override

func NewNextjsBuild_Override(n NextjsBuild, scope constructs.Construct, id *string, props *NextjsBuildProps)

func NewNextjsDistribution_Override

func NewNextjsDistribution_Override(n NextjsDistribution, scope constructs.Construct, id *string, props *NextjsDistributionProps)

func NewNextjsLayer_Override

func NewNextjsLayer_Override(n NextjsLayer, scope constructs.Construct, id *string, props *NextjsLayerProps)

func NewNextjsS3EnvRewriter_Override

func NewNextjsS3EnvRewriter_Override(n NextjsS3EnvRewriter, scope constructs.Construct, id *string, props *NextjsS3EnvRewriterProps)

func NewNextjs_Override

func NewNextjs_Override(n Nextjs, scope constructs.Construct, id *string, props *NextjsProps)

func NextJsAssetsDeployment_IsConstruct

func NextJsAssetsDeployment_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NextJsLambda_IsConstruct

func NextJsLambda_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NextjsBuild_IsConstruct

func NextjsBuild_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NextjsDistribution_FallbackOriginRequestPolicyProps

func NextjsDistribution_FallbackOriginRequestPolicyProps() *awscloudfront.OriginRequestPolicyProps

func NextjsDistribution_ImageCachePolicyProps

func NextjsDistribution_ImageCachePolicyProps() *awscloudfront.CachePolicyProps

func NextjsDistribution_ImageOptimizationOriginRequestPolicyProps

func NextjsDistribution_ImageOptimizationOriginRequestPolicyProps() *awscloudfront.OriginRequestPolicyProps

func NextjsDistribution_IsConstruct

func NextjsDistribution_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NextjsDistribution_LambdaCachePolicyProps

func NextjsDistribution_LambdaCachePolicyProps() *awscloudfront.CachePolicyProps

func NextjsDistribution_LambdaOriginRequestPolicyProps

func NextjsDistribution_LambdaOriginRequestPolicyProps() *awscloudfront.OriginRequestPolicyProps

func NextjsDistribution_SetFallbackOriginRequestPolicyProps

func NextjsDistribution_SetFallbackOriginRequestPolicyProps(val *awscloudfront.OriginRequestPolicyProps)

func NextjsDistribution_SetImageCachePolicyProps

func NextjsDistribution_SetImageCachePolicyProps(val *awscloudfront.CachePolicyProps)

func NextjsDistribution_SetImageOptimizationOriginRequestPolicyProps

func NextjsDistribution_SetImageOptimizationOriginRequestPolicyProps(val *awscloudfront.OriginRequestPolicyProps)

func NextjsDistribution_SetLambdaCachePolicyProps

func NextjsDistribution_SetLambdaCachePolicyProps(val *awscloudfront.CachePolicyProps)

func NextjsDistribution_SetLambdaOriginRequestPolicyProps

func NextjsDistribution_SetLambdaOriginRequestPolicyProps(val *awscloudfront.OriginRequestPolicyProps)

func NextjsDistribution_SetStaticCachePolicyProps

func NextjsDistribution_SetStaticCachePolicyProps(val *awscloudfront.CachePolicyProps)

func NextjsDistribution_StaticCachePolicyProps

func NextjsDistribution_StaticCachePolicyProps() *awscloudfront.CachePolicyProps

func NextjsLayer_FromLayerVersionArn

func NextjsLayer_FromLayerVersionArn(scope constructs.Construct, id *string, layerVersionArn *string) awslambda.ILayerVersion

Imports a layer version by ARN.

Assumes it is compatible with all Lambda runtimes.

func NextjsLayer_FromLayerVersionAttributes

func NextjsLayer_FromLayerVersionAttributes(scope constructs.Construct, id *string, attrs *awslambda.LayerVersionAttributes) awslambda.ILayerVersion

Imports a Layer that has been defined externally.

func NextjsLayer_IsConstruct

func NextjsLayer_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func NextjsLayer_IsOwnedResource

func NextjsLayer_IsOwnedResource(construct constructs.IConstruct) *bool

Returns true if the construct was created by CDK, and false otherwise.

func NextjsLayer_IsResource

func NextjsLayer_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource.

func NextjsS3EnvRewriter_IsConstruct

func NextjsS3EnvRewriter_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

func Nextjs_IsConstruct

func Nextjs_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.

Types

type BaseSiteDomainProps

type BaseSiteDomainProps struct {
	// The domain to be assigned to the website URL (ie. domain.com).
	//
	// Supports domains that are hosted either on [Route 53](https://aws.amazon.com/route53/) or externally.
	DomainName *string `field:"required" json:"domainName" yaml:"domainName"`
	// Specify additional names that should route to the Cloudfront Distribution.
	AlternateNames *[]*string `field:"optional" json:"alternateNames" yaml:"alternateNames"`
	// Import the certificate for the domain.
	//
	// By default, SST will create a certificate with the domain name. The certificate will be created in the `us-east-1`(N. Virginia) region as required by AWS CloudFront.
	//
	// Set this option if you have an existing certificate in the `us-east-1` region in AWS Certificate Manager you want to use.
	Certificate awscertificatemanager.ICertificate `field:"optional" json:"certificate" yaml:"certificate"`
	// An alternative domain to be assigned to the website URL.
	//
	// Visitors to the alias will be redirected to the main domain. (ie. `www.domain.com`).
	//
	// Use this to create a `www.` version of your domain and redirect visitors to the root domain.
	DomainAlias *string `field:"optional" json:"domainAlias" yaml:"domainAlias"`
	// Import the underlying Route 53 hosted zone.
	HostedZone awsroute53.IHostedZone `field:"optional" json:"hostedZone" yaml:"hostedZone"`
	// Set this option if the domain is not hosted on Amazon Route 53.
	IsExternalDomain *bool `field:"optional" json:"isExternalDomain" yaml:"isExternalDomain"`
}

type BaseSiteEnvironmentOutputsInfo

type BaseSiteEnvironmentOutputsInfo struct {
	EnvironmentOutputs *map[string]*string `field:"required" json:"environmentOutputs" yaml:"environmentOutputs"`
	Path               *string             `field:"required" json:"path" yaml:"path"`
	Stack              *string             `field:"required" json:"stack" yaml:"stack"`
}

type BaseSiteReplaceProps

type BaseSiteReplaceProps struct {
	Files   *string `field:"required" json:"files" yaml:"files"`
	Replace *string `field:"required" json:"replace" yaml:"replace"`
	Search  *string `field:"required" json:"search" yaml:"search"`
}

type CreateArchiveArgs

type CreateArchiveArgs struct {
	Directory        *string  `field:"required" json:"directory" yaml:"directory"`
	ZipFileName      *string  `field:"required" json:"zipFileName" yaml:"zipFileName"`
	ZipOutDir        *string  `field:"required" json:"zipOutDir" yaml:"zipOutDir"`
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	FileGlob         *string  `field:"optional" json:"fileGlob" yaml:"fileGlob"`
	Quiet            *bool    `field:"optional" json:"quiet" yaml:"quiet"`
}

type ImageOptimizationLambda

type ImageOptimizationLambda interface {
	awslambda.Function
	// The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64).
	Architecture() awslambda.Architecture
	Bucket() awss3.IBucket
	SetBucket(val awss3.IBucket)
	// Whether the addPermission() call adds any permissions.
	//
	// True for new Lambdas, false for version $LATEST and imported Lambdas
	// from different accounts.
	CanCreatePermissions() *bool
	// Access the Connections object.
	//
	// Will fail if not a VPC-enabled Lambda Function.
	Connections() awsec2.Connections
	// Returns a `lambda.Version` which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes.
	//
	// You can specify options for this version using the `currentVersionOptions`
	// prop when initializing the `lambda.Function`.
	CurrentVersion() awslambda.Version
	// The DLQ (as queue) associated with this Lambda Function (this is an optional attribute).
	DeadLetterQueue() awssqs.IQueue
	// The DLQ (as topic) associated with this Lambda Function (this is an optional attribute).
	DeadLetterTopic() awssns.ITopic
	// The environment this resource belongs to.
	//
	// For resources that are created and managed by the CDK
	// (generally, those created by creating new class instances like Role, Bucket, etc.),
	// this is always the same as the environment of the stack they belong to;
	// however, for imported resources
	// (those obtained from static methods like fromRoleArn, fromBucketName, etc.),
	// that might be different than the stack they were imported into.
	Env() *awscdk.ResourceEnvironment
	// ARN of this function.
	FunctionArn() *string
	// Name of this function.
	FunctionName() *string
	// The principal this Lambda Function is running as.
	GrantPrincipal() awsiam.IPrincipal
	// Whether or not this Lambda function was bound to a VPC.
	//
	// If this is is `false`, trying to access the `connections` object will fail.
	IsBoundToVpc() *bool
	// The `$LATEST` version of this function.
	//
	// Note that this is reference to a non-specific AWS Lambda version, which
	// means the function this version refers to can return different results in
	// different invocations.
	//
	// To obtain a reference to an explicit version which references the current
	// function configuration, use `lambdaFunction.currentVersion` instead.
	LatestVersion() awslambda.IVersion
	// The LogGroup where the Lambda function's logs are made available.
	//
	// If either `logRetention` is set or this property is called, a CloudFormation custom resource is added to the stack that
	// pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention
	// period (never expire, by default).
	//
	// Further, if the log group already exists and the `logRetention` is not set, the custom resource will reset the log retention
	// to never expire even if it was configured with a different value.
	LogGroup() awslogs.ILogGroup
	// The tree node.
	Node() constructs.Node
	// The construct node where permissions are attached.
	PermissionsNode() constructs.Node
	// Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
	//
	// This value will resolve to one of the following:
	// - a concrete value (e.g. `"my-awesome-bucket"`)
	// - `undefined`, when a name should be generated by CloudFormation
	// - a concrete name generated automatically during synthesis, in
	//   cross-environment scenarios.
	PhysicalName() *string
	// The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
	ResourceArnsForGrantInvoke() *[]*string
	// Execution role associated with this function.
	Role() awsiam.IRole
	// The runtime configured for this lambda.
	Runtime() awslambda.Runtime
	// The stack in which this resource is defined.
	Stack() awscdk.Stack
	// The timeout configured for this lambda.
	Timeout() awscdk.Duration
	// Defines an alias for this function.
	//
	// The alias will automatically be updated to point to the latest version of
	// the function as it is being updated during a deployment.
	//
	// “`ts
	// declare const fn: lambda.Function;
	//
	// fn.addAlias('Live');
	//
	// // Is equivalent to
	//
	// new lambda.Alias(this, 'AliasLive', {
	//   aliasName: 'Live',
	//   version: fn.currentVersion,
	// });
	// “`.
	AddAlias(aliasName *string, options *awslambda.AliasOptions) awslambda.Alias
	// Adds an environment variable to this Lambda function.
	//
	// If this is a ref to a Lambda function, this operation results in a no-op.
	AddEnvironment(key *string, value *string, options *awslambda.EnvironmentOptions) awslambda.Function
	// Adds an event source to this function.
	//
	// Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module.
	//
	// The following example adds an SQS Queue as an event source:
	// “`
	// import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
	// myFunction.addEventSource(new SqsEventSource(myQueue));
	// “`.
	AddEventSource(source awslambda.IEventSource)
	// Adds an event source that maps to this AWS Lambda function.
	AddEventSourceMapping(id *string, options *awslambda.EventSourceMappingOptions) awslambda.EventSourceMapping
	// Adds a url to this lambda function.
	AddFunctionUrl(options *awslambda.FunctionUrlOptions) awslambda.FunctionUrl
	// Adds one or more Lambda Layers to this Lambda function.
	AddLayers(layers ...awslambda.ILayerVersion)
	// Adds a permission to the Lambda resource policy.
	// See: Permission for details.
	//
	AddPermission(id *string, permission *awslambda.Permission)
	// Adds a statement to the IAM role assumed by the instance.
	AddToRolePolicy(statement awsiam.PolicyStatement)
	// Apply the given removal policy to this resource.
	//
	// The Removal Policy controls what happens to this resource when it stops
	// being managed by CloudFormation, either because you've removed it from the
	// CDK application or because you've made a change that requires the resource
	// to be replaced.
	//
	// The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
	// account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	// Configures options for asynchronous invocation.
	ConfigureAsyncInvoke(options *awslambda.EventInvokeConfigOptions)
	// A warning will be added to functions under the following conditions: - permissions that include `lambda:InvokeFunction` are added to the unqualified function.
	//
	// - function.currentVersion is invoked before or after the permission is created.
	//
	// This applies only to permissions on Lambda functions, not versions or aliases.
	// This function is overridden as a noOp for QualifiedFunctionBase.
	ConsiderWarningOnInvokeFunctionPermissions(scope constructs.Construct, action *string)
	GeneratePhysicalName() *string
	// Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`).
	//
	// Normally, this token will resolve to `arnAttr`, but if the resource is
	// referenced across environments, `arnComponents` will be used to synthesize
	// a concrete ARN with the resource's physical name. Make sure to reference
	// `this.physicalName` in `arnComponents`.
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	// Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`).
	//
	// Normally, this token will resolve to `nameAttr`, but if the resource is
	// referenced across environments, it will be resolved to `this.physicalName`,
	// which will be a concrete name.
	GetResourceNameAttribute(nameAttr *string) *string
	// Grant the given identity permissions to invoke this Lambda.
	GrantInvoke(grantee awsiam.IGrantable) awsiam.Grant
	// Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
	GrantInvokeCompositePrincipal(compositePrincipal awsiam.CompositePrincipal) *[]awsiam.Grant
	// Grant the given identity permissions to invoke this Lambda Function URL.
	GrantInvokeUrl(grantee awsiam.IGrantable) awsiam.Grant
	// Mix additional information into the hash of the Version object.
	//
	// The Lambda Function construct does its best to automatically create a new
	// Version when anything about the Function changes (its code, its layers,
	// any of the other properties).
	//
	// However, you can sometimes source information from places that the CDK cannot
	// look into, like the deploy-time values of SSM parameters. In those cases,
	// the CDK would not force the creation of a new Version object when it actually
	// should.
	//
	// This method can be used to invalidate the current Version object. Pass in
	// any string into this method, and make sure the string changes when you know
	// a new Version needs to be created.
	//
	// This method may be called more than once.
	InvalidateVersionBasedOn(x *string)
	// Return the given named metric for this Function.
	Metric(metricName *string, props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// How long execution of this Lambda takes.
	//
	// Average over 5 minutes.
	MetricDuration(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// How many invocations of this Lambda fail.
	//
	// Sum over 5 minutes.
	MetricErrors(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// How often this Lambda is invoked.
	//
	// Sum over 5 minutes.
	MetricInvocations(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// How often this Lambda is throttled.
	//
	// Sum over 5 minutes.
	MetricThrottles(props *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Returns a string representation of this construct.
	ToString() *string
	WarnInvokeFunctionPermissions(scope constructs.Construct)
}

This lambda handles image optimization.

func NewImageOptimizationLambda

func NewImageOptimizationLambda(scope constructs.Construct, id *string, props *ImageOptimizationProps) ImageOptimizationLambda

type ImageOptimizationProps

type ImageOptimizationProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// The S3 bucket holding application images.
	Bucket awss3.IBucket `field:"required" json:"bucket" yaml:"bucket"`
	// The `NextjsBuild` instance representing the built Nextjs application.
	NextBuild NextjsBuild `field:"required" json:"nextBuild" yaml:"nextBuild"`
	// Override function properties.
	LambdaOptions *awslambda.FunctionOptions `field:"optional" json:"lambdaOptions" yaml:"lambdaOptions"`
}

type NextJsAssetsDeployment

type NextJsAssetsDeployment interface {
	constructs.Construct
	// Bucket containing assets.
	Bucket() awss3.IBucket
	SetBucket(val awss3.IBucket)
	// Asset deployments to S3.
	Deployments() *[]awss3deployment.BucketDeployment
	SetDeployments(val *[]awss3deployment.BucketDeployment)
	// The tree node.
	Node() constructs.Node
	Props() *NextjsAssetsDeploymentProps
	SetProps(val *NextjsAssetsDeploymentProps)
	Rewriter() NextjsS3EnvRewriter
	SetRewriter(val NextjsS3EnvRewriter)
	StaticTempDir() *string
	SetStaticTempDir(val *string)
	PrepareArchiveDirectory() *string
	// Returns a string representation of this construct.
	ToString() *string
}

Uploads NextJS-built static and public files to S3.

Will rewrite CloudFormation references with their resolved values after uploading.

func NewNextJsAssetsDeployment

func NewNextJsAssetsDeployment(scope constructs.Construct, id *string, props *NextjsAssetsDeploymentProps) NextJsAssetsDeployment

type NextJsLambda

type NextJsLambda interface {
	constructs.Construct
	ConfigBucket() awss3.Bucket
	SetConfigBucket(val awss3.Bucket)
	LambdaFunction() awslambda.Function
	SetLambdaFunction(val awslambda.Function)
	// The tree node.
	Node() constructs.Node
	CreateConfigBucket(replacementParams *map[string]*string) *map[string]interface{}
	// Returns a string representation of this construct.
	ToString() *string
}

Build a lambda function from a NextJS application to handle server-side rendering, API routes, and image optimization.

func NewNextJsLambda

func NewNextJsLambda(scope constructs.Construct, id *string, props *NextjsLambdaProps) NextJsLambda

type Nextjs

type Nextjs interface {
	constructs.Construct
	// Asset deployment to S3.
	AssetsDeployment() NextJsAssetsDeployment
	SetAssetsDeployment(val NextJsAssetsDeployment)
	Bucket() awss3.IBucket
	ConfigBucket() awss3.Bucket
	SetConfigBucket(val awss3.Bucket)
	// CloudFront distribution.
	Distribution() NextjsDistribution
	SetDistribution(val NextjsDistribution)
	// The image optimization handler lambda function.
	ImageOptimizationFunction() ImageOptimizationLambda
	SetImageOptimizationFunction(val ImageOptimizationLambda)
	ImageOptimizationLambdaFunctionUrl() awslambda.FunctionUrl
	SetImageOptimizationLambdaFunctionUrl(val awslambda.FunctionUrl)
	LambdaFunctionUrl() awslambda.FunctionUrl
	SetLambdaFunctionUrl(val awslambda.FunctionUrl)
	// Built NextJS project output.
	NextBuild() NextjsBuild
	SetNextBuild(val NextjsBuild)
	// The tree node.
	Node() constructs.Node
	Props() *NextjsProps
	SetProps(val *NextjsProps)
	// The main NextJS server handler lambda function.
	ServerFunction() NextJsLambda
	SetServerFunction(val NextJsLambda)
	StaticAssetBucket() awss3.IBucket
	SetStaticAssetBucket(val awss3.IBucket)
	// Where build-time assets for deployment are stored.
	TempBuildDir() *string
	SetTempBuildDir(val *string)
	Url() *string
	// Returns a string representation of this construct.
	ToString() *string
}

The `Nextjs` construct is a higher level construct that makes it easy to create a NextJS app.

Your standalone server application will be bundled using o(utput tracing and will be deployed to a Lambda function. Static assets will be deployed to an S3 bucket and served via CloudFront. You must use Next.js 10.3.0 or newer.

Please provide a `nextjsPath` to the Next.js app inside your project.

Example:

new Nextjs(this, "Web", {
  nextjsPath: path.resolve("packages/web"),
})

func NewNextjs

func NewNextjs(scope constructs.Construct, id *string, props *NextjsProps) Nextjs

type NextjsAssetsCachePolicyProps

type NextjsAssetsCachePolicyProps struct {
	// Cache-control max-age default for S3 static assets.
	//
	// Default: 30 days.
	StaticMaxAgeDefault awscdk.Duration `field:"optional" json:"staticMaxAgeDefault" yaml:"staticMaxAgeDefault"`
	// Cache-control stale-while-revalidate default for S3 static assets.
	//
	// Default: 1 day.
	StaticStaleWhileRevalidateDefault awscdk.Duration `field:"optional" json:"staticStaleWhileRevalidateDefault" yaml:"staticStaleWhileRevalidateDefault"`
}

type NextjsAssetsDeploymentProps

type NextjsAssetsDeploymentProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// Properties for the S3 bucket containing the NextJS assets.
	Bucket awss3.IBucket `field:"required" json:"bucket" yaml:"bucket"`
	// The `NextjsBuild` instance representing the built Nextjs application.
	NextBuild NextjsBuild `field:"required" json:"nextBuild" yaml:"nextBuild"`
	// Override the default S3 cache policies created internally.
	CachePolicies *NextjsAssetsCachePolicyProps `field:"optional" json:"cachePolicies" yaml:"cachePolicies"`
	// Distribution to invalidate when assets change.
	Distribution awscloudfront.IDistribution `field:"optional" json:"distribution" yaml:"distribution"`
	// ephemeralStorageSize for lambda function which been run by BucketDeployment.
	EphemeralStorageSize awscdk.Size `field:"optional" json:"ephemeralStorageSize" yaml:"ephemeralStorageSize"`
	// memoryLimit for lambda function which been run by BucketDeployment.
	MemoryLimit *float64 `field:"optional" json:"memoryLimit" yaml:"memoryLimit"`
	// Set to true to delete old assets (defaults to false).
	//
	// Recommended to only set to true if you don't need the ability to roll back deployments.
	Prune *bool `field:"optional" json:"prune" yaml:"prune"`
	// In case of useEfs, vpc is required.
	UseEfs *bool `field:"optional" json:"useEfs" yaml:"useEfs"`
	// In case of useEfs, vpc is required.
	Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"`
}

type NextjsAssetsDeploymentPropsDefaults added in v0.0.5

type NextjsAssetsDeploymentPropsDefaults struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// Properties for the S3 bucket containing the NextJS assets.
	Bucket awss3.IBucket `field:"optional" json:"bucket" yaml:"bucket"`
	// Override the default S3 cache policies created internally.
	CachePolicies *NextjsAssetsCachePolicyProps `field:"optional" json:"cachePolicies" yaml:"cachePolicies"`
	// Distribution to invalidate when assets change.
	Distribution awscloudfront.IDistribution `field:"optional" json:"distribution" yaml:"distribution"`
	// ephemeralStorageSize for lambda function which been run by BucketDeployment.
	EphemeralStorageSize awscdk.Size `field:"optional" json:"ephemeralStorageSize" yaml:"ephemeralStorageSize"`
	// memoryLimit for lambda function which been run by BucketDeployment.
	MemoryLimit *float64 `field:"optional" json:"memoryLimit" yaml:"memoryLimit"`
	// The `NextjsBuild` instance representing the built Nextjs application.
	NextBuild NextjsBuild `field:"optional" json:"nextBuild" yaml:"nextBuild"`
	// Set to true to delete old assets (defaults to false).
	//
	// Recommended to only set to true if you don't need the ability to roll back deployments.
	Prune *bool `field:"optional" json:"prune" yaml:"prune"`
	// In case of useEfs, vpc is required.
	UseEfs *bool `field:"optional" json:"useEfs" yaml:"useEfs"`
	// In case of useEfs, vpc is required.
	Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"`
}

Effectively a Partial<NextjsAssetsCachePolicyProps> to satisfy JSII.

type NextjsBaseProps

type NextjsBaseProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
}

Common props shared across NextJS-related CDK constructs.

type NextjsBuild

type NextjsBuild interface {
	constructs.Construct
	// Contains function for processessing image requests.
	//
	// Should be arm64.
	NextImageFnDir() *string
	SetNextImageFnDir(val *string)
	// Contains code for middleware.
	//
	// Not currently used.
	NextMiddlewareFnDir() *string
	SetNextMiddlewareFnDir(val *string)
	// Contains server code and dependencies.
	NextServerFnDir() *string
	SetNextServerFnDir(val *string)
	// Static files containing client-side code.
	NextStaticDir() *string
	SetNextStaticDir(val *string)
	// The tree node.
	Node() constructs.Node
	OpenNextPath() *string
	Props() *NextjsBuildProps
	SetProps(val *NextjsBuildProps)
	ReadPublicFileList() *[]*string
	// Returns a string representation of this construct.
	ToString() *string
}

Represents a built NextJS application.

This construct runs `npm build` in standalone output mode inside your `nextjsPath`. This construct can be used by higher level constructs or used directly.

func NewNextjsBuild

func NewNextjsBuild(scope constructs.Construct, id *string, props *NextjsBuildProps) NextjsBuild

type NextjsBuildProps

type NextjsBuildProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
}

type NextjsCachePolicyProps

type NextjsCachePolicyProps struct {
	ImageCachePolicy  awscloudfront.ICachePolicy `field:"optional" json:"imageCachePolicy" yaml:"imageCachePolicy"`
	LambdaCachePolicy awscloudfront.ICachePolicy `field:"optional" json:"lambdaCachePolicy" yaml:"lambdaCachePolicy"`
	StaticCachePolicy awscloudfront.ICachePolicy `field:"optional" json:"staticCachePolicy" yaml:"staticCachePolicy"`
	// Cache-control max-age default for static assets (/_next/*).
	//
	// Default: 30 days.
	StaticClientMaxAgeDefault awscdk.Duration `field:"optional" json:"staticClientMaxAgeDefault" yaml:"staticClientMaxAgeDefault"`
}

type NextjsDefaultsProps

type NextjsDefaultsProps struct {
	// Override static file deployment settings.
	AssetDeployment *NextjsAssetsDeploymentPropsDefaults `field:"optional" json:"assetDeployment" yaml:"assetDeployment"`
	// Override CloudFront distribution settings.
	Distribution *NextjsDistributionPropsDefaults `field:"optional" json:"distribution" yaml:"distribution"`
	// Override server lambda function settings.
	Lambda *awslambda.FunctionOptions `field:"optional" json:"lambda" yaml:"lambda"`
}

Defaults for created resources.

Why `any`? see https://github.com/aws/jsii/issues/2901

type NextjsDistribution

type NextjsDistribution interface {
	constructs.Construct
	// The AWS Certificate Manager certificate for the custom domain.
	Certificate() awscertificatemanager.ICertificate
	SetCertificate(val awscertificatemanager.ICertificate)
	CustomDomainName() *string
	// If the custom domain is enabled, this is the URL of the website with the custom domain.
	CustomDomainUrl() *string
	// The internally created CloudFront `Distribution` instance.
	Distribution() awscloudfront.Distribution
	SetDistribution(val awscloudfront.Distribution)
	// The domain name of the internally created CloudFront Distribution.
	DistributionDomain() *string
	// The ID of the internally created CloudFront Distribution.
	DistributionId() *string
	// The Route 53 hosted zone for the custom domain.
	HostedZone() awsroute53.IHostedZone
	SetHostedZone(val awsroute53.IHostedZone)
	// The tree node.
	Node() constructs.Node
	Props() *NextjsDistributionProps
	SetProps(val *NextjsDistributionProps)
	TempBuildDir() *string
	SetTempBuildDir(val *string)
	// The CloudFront URL of the website.
	Url() *string
	LookupHostedZone() awsroute53.IHostedZone
	// Returns a string representation of this construct.
	ToString() *string
	ValidateCustomDomainSettings()
}

Create a CloudFront distribution to serve a Next.js application.

func NewNextjsDistribution

func NewNextjsDistribution(scope constructs.Construct, id *string, props *NextjsDistributionProps) NextjsDistribution

type NextjsDistributionCdkProps

type NextjsDistributionCdkProps struct {
	// Pass in a value to override the default settings this construct uses to create the CloudFront `Distribution` internally.
	Distribution *awscloudfront.DistributionProps `field:"optional" json:"distribution" yaml:"distribution"`
}

type NextjsDistributionProps

type NextjsDistributionProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// Lambda function to optimize images.
	//
	// Must be provided if you want to serve dynamic requests.
	ImageOptFunction awslambda.IFunction `field:"required" json:"imageOptFunction" yaml:"imageOptFunction"`
	// Built NextJS app.
	NextBuild NextjsBuild `field:"required" json:"nextBuild" yaml:"nextBuild"`
	// Lambda function to route all non-static requests to.
	//
	// Must be provided if you want to serve dynamic requests.
	ServerFunction awslambda.IFunction `field:"required" json:"serverFunction" yaml:"serverFunction"`
	// Bucket containing static assets.
	//
	// Must be provided if you want to serve static files.
	StaticAssetsBucket awss3.IBucket `field:"required" json:"staticAssetsBucket" yaml:"staticAssetsBucket"`
	// Override the default CloudFront cache policies created internally.
	CachePolicies *NextjsCachePolicyProps `field:"optional" json:"cachePolicies" yaml:"cachePolicies"`
	// Overrides for created CDK resources.
	Cdk *NextjsDistributionCdkProps `field:"optional" json:"cdk" yaml:"cdk"`
	// The customDomain for this website. Supports domains that are hosted either on [Route 53](https://aws.amazon.com/route53/) or externally.
	//
	// Note that you can also migrate externally hosted domains to Route 53 by
	// [following this guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html).
	//
	// Example:
	//   new NextjsDistribution(this, "Dist", {
	//     customDomain: "domain.com",
	//   });
	//
	//   new NextjsDistribution(this, "Dist", {
	//     customDomain: {
	//       domainName: "domain.com",
	//       domainAlias: "www.domain.com",
	//       hostedZone: "domain.com"
	//     },
	//   });
	//
	CustomDomain interface{} `field:"optional" json:"customDomain" yaml:"customDomain"`
	// Override lambda function url auth type.
	// Default: "NONE".
	//
	FunctionUrlAuthType awslambda.FunctionUrlAuthType `field:"optional" json:"functionUrlAuthType" yaml:"functionUrlAuthType"`
	// Override the default CloudFront origin request policies created internally.
	OriginRequestPolicies *NextjsOriginRequestPolicyProps `field:"optional" json:"originRequestPolicies" yaml:"originRequestPolicies"`
	// Optional value to prefix the edge function stack It defaults to "Nextjs".
	StackPrefix *string `field:"optional" json:"stackPrefix" yaml:"stackPrefix"`
	// Include the name of your deployment stage if present.
	//
	// Used to name the edge functions stack.
	// Required if using SST.
	StageName *string `field:"optional" json:"stageName" yaml:"stageName"`
}

type NextjsDistributionPropsDefaults added in v0.0.5

type NextjsDistributionPropsDefaults struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// Override the default CloudFront cache policies created internally.
	CachePolicies *NextjsCachePolicyProps `field:"optional" json:"cachePolicies" yaml:"cachePolicies"`
	// Overrides for created CDK resources.
	Cdk *NextjsDistributionCdkProps `field:"optional" json:"cdk" yaml:"cdk"`
	// The customDomain for this website. Supports domains that are hosted either on [Route 53](https://aws.amazon.com/route53/) or externally.
	//
	// Note that you can also migrate externally hosted domains to Route 53 by
	// [following this guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/MigratingDNS.html).
	//
	// Example:
	//   new NextjsDistribution(this, "Dist", {
	//     customDomain: "domain.com",
	//   });
	//
	//   new NextjsDistribution(this, "Dist", {
	//     customDomain: {
	//       domainName: "domain.com",
	//       domainAlias: "www.domain.com",
	//       hostedZone: "domain.com"
	//     },
	//   });
	//
	CustomDomain interface{} `field:"optional" json:"customDomain" yaml:"customDomain"`
	// Override lambda function url auth type.
	// Default: "NONE".
	//
	FunctionUrlAuthType awslambda.FunctionUrlAuthType `field:"optional" json:"functionUrlAuthType" yaml:"functionUrlAuthType"`
	// Lambda function to optimize images.
	//
	// Must be provided if you want to serve dynamic requests.
	ImageOptFunction awslambda.IFunction `field:"optional" json:"imageOptFunction" yaml:"imageOptFunction"`
	// Built NextJS app.
	NextBuild NextjsBuild `field:"optional" json:"nextBuild" yaml:"nextBuild"`
	// Override the default CloudFront origin request policies created internally.
	OriginRequestPolicies *NextjsOriginRequestPolicyProps `field:"optional" json:"originRequestPolicies" yaml:"originRequestPolicies"`
	// Lambda function to route all non-static requests to.
	//
	// Must be provided if you want to serve dynamic requests.
	ServerFunction awslambda.IFunction `field:"optional" json:"serverFunction" yaml:"serverFunction"`
	// Optional value to prefix the edge function stack It defaults to "Nextjs".
	StackPrefix *string `field:"optional" json:"stackPrefix" yaml:"stackPrefix"`
	// Include the name of your deployment stage if present.
	//
	// Used to name the edge functions stack.
	// Required if using SST.
	StageName *string `field:"optional" json:"stageName" yaml:"stageName"`
	// Bucket containing static assets.
	//
	// Must be provided if you want to serve static files.
	StaticAssetsBucket awss3.IBucket `field:"optional" json:"staticAssetsBucket" yaml:"staticAssetsBucket"`
}

Effectively a Partial<NextjsDistributionProps> to satisfy JSII.

type NextjsDomainProps

type NextjsDomainProps struct {
	// The domain to be assigned to the website URL (ie. domain.com).
	//
	// Supports domains that are hosted either on [Route 53](https://aws.amazon.com/route53/) or externally.
	DomainName *string `field:"required" json:"domainName" yaml:"domainName"`
	// Specify additional names that should route to the Cloudfront Distribution.
	AlternateNames *[]*string `field:"optional" json:"alternateNames" yaml:"alternateNames"`
	// Import the certificate for the domain.
	//
	// By default, SST will create a certificate with the domain name. The certificate will be created in the `us-east-1`(N. Virginia) region as required by AWS CloudFront.
	//
	// Set this option if you have an existing certificate in the `us-east-1` region in AWS Certificate Manager you want to use.
	Certificate awscertificatemanager.ICertificate `field:"optional" json:"certificate" yaml:"certificate"`
	// An alternative domain to be assigned to the website URL.
	//
	// Visitors to the alias will be redirected to the main domain. (ie. `www.domain.com`).
	//
	// Use this to create a `www.` version of your domain and redirect visitors to the root domain.
	DomainAlias *string `field:"optional" json:"domainAlias" yaml:"domainAlias"`
	// Import the underlying Route 53 hosted zone.
	HostedZone awsroute53.IHostedZone `field:"optional" json:"hostedZone" yaml:"hostedZone"`
	// Set this option if the domain is not hosted on Amazon Route 53.
	IsExternalDomain *bool `field:"optional" json:"isExternalDomain" yaml:"isExternalDomain"`
}

type NextjsLambdaProps

type NextjsLambdaProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// Built nextJS application.
	NextBuild NextjsBuild `field:"required" json:"nextBuild" yaml:"nextBuild"`
	// Override function properties.
	Lambda *awslambda.FunctionOptions `field:"optional" json:"lambda" yaml:"lambda"`
}

type NextjsLayer

type NextjsLayer interface {
	awslambda.LayerVersion
	// The runtimes compatible with this Layer.
	CompatibleRuntimes() *[]awslambda.Runtime
	// The environment this resource belongs to.
	//
	// For resources that are created and managed by the CDK
	// (generally, those created by creating new class instances like Role, Bucket, etc.),
	// this is always the same as the environment of the stack they belong to;
	// however, for imported resources
	// (those obtained from static methods like fromRoleArn, fromBucketName, etc.),
	// that might be different than the stack they were imported into.
	Env() *awscdk.ResourceEnvironment
	// The ARN of the Lambda Layer version that this Layer defines.
	LayerVersionArn() *string
	// The tree node.
	Node() constructs.Node
	// Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
	//
	// This value will resolve to one of the following:
	// - a concrete value (e.g. `"my-awesome-bucket"`)
	// - `undefined`, when a name should be generated by CloudFormation
	// - a concrete name generated automatically during synthesis, in
	//   cross-environment scenarios.
	PhysicalName() *string
	// The stack in which this resource is defined.
	Stack() awscdk.Stack
	// Add permission for this layer version to specific entities.
	//
	// Usage within
	// the same account where the layer is defined is always allowed and does not
	// require calling this method. Note that the principal that creates the
	// Lambda function using the layer (for example, a CloudFormation changeset
	// execution role) also needs to have the “lambda:GetLayerVersion“
	// permission on the layer version.
	AddPermission(id *string, permission *awslambda.LayerVersionPermission)
	// Apply the given removal policy to this resource.
	//
	// The Removal Policy controls what happens to this resource when it stops
	// being managed by CloudFormation, either because you've removed it from the
	// CDK application or because you've made a change that requires the resource
	// to be replaced.
	//
	// The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
	// account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	GeneratePhysicalName() *string
	// Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`).
	//
	// Normally, this token will resolve to `arnAttr`, but if the resource is
	// referenced across environments, `arnComponents` will be used to synthesize
	// a concrete ARN with the resource's physical name. Make sure to reference
	// `this.physicalName` in `arnComponents`.
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	// Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`).
	//
	// Normally, this token will resolve to `nameAttr`, but if the resource is
	// referenced across environments, it will be resolved to `this.physicalName`,
	// which will be a concrete name.
	GetResourceNameAttribute(nameAttr *string) *string
	// Returns a string representation of this construct.
	ToString() *string
}

Lambda layer for Next.js. Contains Sharp 0.30.0.

func NewNextjsLayer

func NewNextjsLayer(scope constructs.Construct, id *string, props *NextjsLayerProps) NextjsLayer

type NextjsLayerProps

type NextjsLayerProps struct {
}

type NextjsOriginRequestPolicyProps

type NextjsOriginRequestPolicyProps struct {
	FallbackOriginRequestPolicy          awscloudfront.IOriginRequestPolicy `field:"optional" json:"fallbackOriginRequestPolicy" yaml:"fallbackOriginRequestPolicy"`
	ImageOptimizationOriginRequestPolicy awscloudfront.IOriginRequestPolicy `field:"optional" json:"imageOptimizationOriginRequestPolicy" yaml:"imageOptimizationOriginRequestPolicy"`
	LambdaOriginRequestPolicy            awscloudfront.IOriginRequestPolicy `field:"optional" json:"lambdaOriginRequestPolicy" yaml:"lambdaOriginRequestPolicy"`
}

type NextjsProps

type NextjsProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir *string `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	// Allows you to override defaults for the resources created by this construct.
	Defaults *NextjsDefaultsProps `field:"optional" json:"defaults" yaml:"defaults"`
	// Optional S3 Bucket to use, defaults to assets bucket.
	ImageOptimizationBucket awss3.IBucket `field:"optional" json:"imageOptimizationBucket" yaml:"imageOptimizationBucket"`
}

type NextjsS3EnvRewriter

type NextjsS3EnvRewriter interface {
	constructs.Construct
	// The tree node.
	Node() constructs.Node
	RewriteNode() constructs.Construct
	SetRewriteNode(val constructs.Construct)
	// Returns a string representation of this construct.
	ToString() *string
}

Rewrites variables in S3 objects after a deployment happens to replace CloudFormation tokens with their values.

These values are not resolved at build time because they are only known at deploy time.

func NewNextjsS3EnvRewriter

func NewNextjsS3EnvRewriter(scope constructs.Construct, id *string, props *NextjsS3EnvRewriterProps) NextjsS3EnvRewriter

type NextjsS3EnvRewriterProps

type NextjsS3EnvRewriterProps struct {
	// Optional value used to install NextJS node dependencies.
	//
	// It defaults to 'npx --yes open-next@1 build'.
	BuildCommand *string `field:"optional" json:"buildCommand" yaml:"buildCommand"`
	// The directory to execute `npm run build` from.
	//
	// By default, it is `nextjsPath`.
	// Can be overridden, particularly useful for monorepos where `build` is expected to run
	// at the root of the project.
	BuildPath *string `field:"optional" json:"buildPath" yaml:"buildPath"`
	// 0 - no compression, fastest 9 - maximum compression, slowest.
	// Default: 1.
	//
	CompressionLevel *float64 `field:"optional" json:"compressionLevel" yaml:"compressionLevel"`
	// Custom environment variables to pass to the NextJS build and runtime.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// Used in conjunction with nextJsPath to skip building NextJS app and assume .open-next folder already exists. Useful when using `next dev` for local development.
	// Deprecated: use `openNextPath` instead.
	IsPlaceholder *bool `field:"optional" json:"isPlaceholder" yaml:"isPlaceholder"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath`, `nextJsPath` or `nextjsPath` must be supplied.
	// Deprecated: use `nextJsPath` instead.
	NextjsPath *string `field:"optional" json:"nextjsPath" yaml:"nextjsPath"`
	// Relative path to the directory where the NextJS project is located.
	//
	// Can be the root of your project (`.`) or a subdirectory (`packages/web`).
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	NextJsPath *string `field:"optional" json:"nextJsPath" yaml:"nextJsPath"`
	// Optional value for NODE_ENV during build and runtime.
	NodeEnv *string `field:"optional" json:"nodeEnv" yaml:"nodeEnv"`
	// Relative path to the OpenNext package named `.open-next` by default.
	//
	// One of `openNextPath` or `nextJsPath` must be supplied.
	OpenNextPath *string `field:"optional" json:"openNextPath" yaml:"openNextPath"`
	// Less build output.
	Quiet *bool `field:"optional" json:"quiet" yaml:"quiet"`
	// Optional arn for the sharp lambda layer.
	//
	// If omitted, the layer will be created.
	SharpLayerArn *string `field:"optional" json:"sharpLayerArn" yaml:"sharpLayerArn"`
	// Directory to store temporary build files in.
	//
	// Defaults to os.tmpdir().
	TempBuildDir             *string                    `field:"optional" json:"tempBuildDir" yaml:"tempBuildDir"`
	ReplacementConfig        *RewriteReplacementsConfig `field:"required" json:"replacementConfig" yaml:"replacementConfig"`
	S3Bucket                 awss3.IBucket              `field:"required" json:"s3Bucket" yaml:"s3Bucket"`
	S3keys                   *[]*string                 `field:"required" json:"s3keys" yaml:"s3keys"`
	CloudfrontDistributionId *string                    `field:"optional" json:"cloudfrontDistributionId" yaml:"cloudfrontDistributionId"`
	Debug                    *bool                      `field:"optional" json:"debug" yaml:"debug"`
}

type RewriteReplacementsConfig

type RewriteReplacementsConfig struct {
	Env          *map[string]*string `field:"optional" json:"env" yaml:"env"`
	JsonS3Bucket awss3.IBucket       `field:"optional" json:"jsonS3Bucket" yaml:"jsonS3Bucket"`
	JsonS3Key    *string             `field:"optional" json:"jsonS3Key" yaml:"jsonS3Key"`
}

type RewriterParams

type RewriterParams struct {
	ReplacementConfig        *RewriteReplacementsConfig `field:"required" json:"replacementConfig" yaml:"replacementConfig"`
	S3Bucket                 awss3.IBucket              `field:"required" json:"s3Bucket" yaml:"s3Bucket"`
	S3keys                   *[]*string                 `field:"required" json:"s3keys" yaml:"s3keys"`
	CloudfrontDistributionId *string                    `field:"optional" json:"cloudfrontDistributionId" yaml:"cloudfrontDistributionId"`
	Debug                    *bool                      `field:"optional" json:"debug" yaml:"debug"`
}

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL