deploy-time-build
Version:
Build during CDK deployment.
85 lines (84 loc) • 3.08 kB
TypeScript
import { IDistribution } from 'aws-cdk-lib/aws-cloudfront';
import { IGrantable, IPrincipal } from 'aws-cdk-lib/aws-iam';
import { IBucket } from 'aws-cdk-lib/aws-s3';
import { AssetProps } from 'aws-cdk-lib/aws-s3-assets';
import { Construct } from 'constructs';
export interface AssetConfig extends AssetProps {
/**
* Shell commands executed right after the asset zip is extracted to the build environment.
* @default No command is executed.
*/
readonly commands?: string[];
/**
* Relative path from a build directory to the directory where the asset is extracted.
* @default basename of the asset path.
*/
readonly extractPath?: string;
}
export interface NodejsBuildProps {
/**
* The AssetProps from which s3-assets are created and copied to the build environment.
*/
readonly assets: AssetConfig[];
/**
* Environment variables injected to the build environment.
* You can use CDK deploy-time values as well as literals.
* @default {}
*/
readonly buildEnvironment?: {
[key: string]: string;
};
/**
* S3 Bucket to which your build artifacts are finally deployed.
*/
readonly destinationBucket: IBucket;
/**
* Key prefix to deploy your build artifact.
* @default '/'
*/
readonly destinationKeyPrefix?: string;
/**
* The distribution you are using to publish you build artifact.
* If any specified, the caches are invalidated on new artifact deployments.
* @default No distribution
*/
readonly distribution?: IDistribution;
/**
* Shell commands to build your project. They are executed on the working directory you specified.
* @default ['npm run build']
*/
readonly buildCommands?: string[];
/**
* Relative path from the build directory to the directory where build commands run.
* @default assetProps[0].extractPath
*/
readonly workingDirectory?: string;
/**
* Relative path from the working directory to the directory where the build artifacts are output.
*/
readonly outputSourceDirectory: string;
/**
* The version of Node.js to use in a build environment. Available versions: 12, 14, 16, 18, 20.
* @default 18
*/
readonly nodejsVersion?: number;
/**
* If true, a .env file is uploaded to an S3 bucket with values of `buildEnvironment` property.
* You can copy it to your local machine by running the command in the stack output.
* @default false
*/
readonly outputEnvFile?: boolean;
/**
* If true, common unnecessary files/directories such as .DS_Store, .git, node_modules, etc are excluded
* from the assets by default.
* @default true
*/
readonly excludeCommonFiles?: boolean;
}
/**
* Build Node.js app and optionally publish the artifact to an S3 bucket.
*/
export declare class NodejsBuild extends Construct implements IGrantable {
readonly grantPrincipal: IPrincipal;
constructor(scope: Construct, id: string, props: NodejsBuildProps);
}