Skip to content

Commit

Permalink
feat: add useEfs and vpc properties to NextjsAssetsDeployme… (#94)
Browse files Browse the repository at this point in the history
* 📝 docs(API.md): add useEfs and vpc properties to NextjsAssetsDeploymentProps class

🚀 feat(NextjsAssetsDeployment.ts): add support for useEfs and vpc options in NextJsAssetsDeploymentProps interface and deploy method

* 🔥 refactor(Nextjs.ts): move distribution initialization to the top of the constructor
🐛 fix(Nextjs.ts): pass the correct staticAssetsBucket to the distribution constructor
🚀 chore(Nextjs.ts): add distribution to assetsDeployment dependencies

🚀 feat(NextjsAssetsDeployment.ts): add memoryLimit and ephemeralStorageSize options for lambda function used by BucketDeployment
🚀 feat(NextjsAssetsDeployment.ts): add distributionPaths option to BucketDeployment based on distributionId in NextjsBaseProps

* 🐛 fix(Nextjs.ts): move distribution initialization after assetsDeployment initialization
✨ feat(Nextjs.ts): add support for distribution in assetsDeployment
🐛 fix(NextjsAssetsDeployment.ts): remove distributionPaths property if distribution is not defined

* 🐛 fix(Nextjs.ts): use correct property for static assets bucket in NextjsDistribution constructor

* 📝 docs(API.md): add documentation for ephemeralStorageSize and memoryLimit properties in NextjsAssetsDeploymentProps class

---------

Co-authored-by: durga <[email protected]>
  • Loading branch information
Durgaprasad-Budhwani and durga authored Mar 21, 2023
1 parent 566c315 commit 314f046
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
52 changes: 52 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class Nextjs extends Construct {
bucket: props.imageOptimizationBucket || this.bucket,
lambdaOptions: props.defaults?.lambda,
});

// deploy nextjs static assets to s3
this.assetsDeployment = new NextJsAssetsDeployment(this, 'AssetDeployment', {
...props,
Expand Down
27 changes: 26 additions & 1 deletion src/NextjsAssetsDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as os from 'os';
import * as path from 'path';
import { Duration } from 'aws-cdk-lib';
import { Duration, Size } from 'aws-cdk-lib';
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import { IVpc } from 'aws-cdk-lib/aws-ec2';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { BucketDeployment, CacheControl, Source } from 'aws-cdk-lib/aws-s3-deployment';
import { Construct } from 'constructs';
Expand Down Expand Up @@ -51,6 +52,26 @@ export interface NextjsAssetsDeploymentProps extends NextjsBaseProps {
* Recommended to only set to true if you don't need the ability to roll back deployments.
*/
readonly prune?: boolean;

/**
* In case of useEfs, vpc is required
*/
readonly vpc?: IVpc;

/**
* In case of useEfs, vpc is required
*/
readonly useEfs?: boolean;

/**
* memoryLimit for lambda function which been run by BucketDeployment
*/
readonly memoryLimit?: number;

/**
* ephemeralStorageSize for lambda function which been run by BucketDeployment
*/
readonly ephemeralStorageSize?: Size;
}

/**
Expand Down Expand Up @@ -162,6 +183,10 @@ export class NextJsAssetsDeployment extends Construct {
sources: [Source.asset(archiveZipFilePath)],
distribution: this.props.distribution,
prune: this.props.prune,
useEfs: this.props.useEfs,
vpc: this.props.vpc,
memoryLimit: this.props.memoryLimit,
ephemeralStorageSize: this.props.ephemeralStorageSize,
});

return [deployment];
Expand Down

0 comments on commit 314f046

Please sign in to comment.