@capraconsulting/webapp-deploy-lambda
Version:
CDK construct for deploying a webapp release to S3 and CloudFront
65 lines (64 loc) • 2.01 kB
TypeScript
import * as constructs from "constructs";
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as s3 from "aws-cdk-lib/aws-s3";
import * as cdk from "aws-cdk-lib";
import { ISource } from "./source";
export interface WebappDeployProps {
/**
* Optional S3 bucket that can be used for deployment from outside CDK.
*
* If specified a policy is added so the deploy function can read from
* the bucket.
*
* @default - none
*/
buildsBucket?: s3.IBucket;
/**
* CloudFront Distribution to be invalidated after deploy.
*
* @default - none
*/
distribution?: cloudfront.IDistribution;
/**
* Regex for patterns of files to be discarded during deployment.
*
* Example: `\.map$` will exclude `js/myapp-1b22c248f.js.map`.
*
* @default - none
*/
excludePattern?: string;
/**
* The time when a deployment is considered old and will be deleted
* unless it is the newest old deployment.
*
* @default - 5 days
*/
pruneDeploymentsOlderThan?: cdk.Duration;
/**
* Name of the lambda function to be created.
*
* @default cdk.PhysicalName.GENERATE_IF_NEEDED
*/
functionName?: string;
/**
* Name of S3 bucket where the contents of the artifacts will be deployed.
* The files will be deployed under the key "web", which is then expected
* to be the origin for the CloudFront distribution
*/
webBucket: s3.IBucket;
/**
* Specific artifact to be deployed to the bucket during CDK deployment.
*
* @default - none
*/
source?: ISource;
}
/**
* Resource to deploy a webapp from a build artifact into an existing
* S3 Bucket and CloudFront Distribution.
*/
export declare class WebappDeploy extends constructs.Construct {
readonly deployFn: lambda.Function;
constructor(scope: constructs.Construct, id: string, props: WebappDeployProps);
}