cdk-efs-assets
Version:
Amazon EFS assets from Github repositories or S3 buckets
131 lines (130 loc) • 4.29 kB
TypeScript
import * as cdk from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as efs from 'aws-cdk-lib/aws-efs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
export interface SyncSourceProps {
/**
* The VPC of the Amazon EFS Filesystem.
*/
readonly vpc: ec2.IVpc;
/**
* Where to place the network interfaces within the VPC.
*/
readonly vpcSubnets?: ec2.SubnetSelection;
/**
* Timeout duration for sync Lambda function. (optional, default: Duration.minutes(3))
*/
readonly timeout?: cdk.Duration;
/**
* The (absolute) directory path inside the EFS AccessPoint to sync files to. Specify '/' to restore synced files to the root
* directory. (optional, default: a source-specific directory path. For example, for the GitHub source, the default
* behavior is to restore to a directory matching the name of the repository)
*/
readonly syncDirectoryPath?: string;
}
export interface GithubSecret {
/**
* The secret ID from AWS Secrets Manager
*/
readonly id: string;
/**
* The key of the secret
*/
readonly key: string;
}
export interface GithubSourceProps extends SyncSourceProps {
/**
* The github repository HTTP URI.
*/
readonly repository: string;
/**
* The github secret for the private repository
*/
readonly secret?: GithubSecret;
}
export interface S3ArchiveSourceProps extends SyncSourceProps {
/**
* The S3 bucket containing the archive file.
*/
readonly bucket: s3.IBucket;
/**
* The path of the zip file to extract in the S3 bucket.
*/
readonly zipFilePath: string;
/**
* If this is set to true, then whenever a new object is uploaded to the specified path,
* an EFS sync will be triggered. Currently, this functionality depends on at least one CloudTrail Trail
* existing in your account that captures the S3 event.
*
* The option is only available with the `LAMBDA` sync engine.
*
* @default true
*/
readonly syncOnUpdate?: boolean;
}
export interface FargateTaskConfig {
readonly task: ecs.TaskDefinition;
/**
* The security group of the fargate task
*/
readonly securityGroup: ec2.ISecurityGroup;
}
export declare abstract class SyncSource {
static github(props: GithubSourceProps): SyncSource;
static s3Archive(props: S3ArchiveSourceProps): SyncSource;
/** @internal */
abstract _createHandler(accessPoint: efs.AccessPoint): lambda.Function;
/** @internal */
abstract _createFargateTask(id: string, accessPoint: efs.AccessPoint): FargateTaskConfig;
}
export declare class GithubSyncSource extends SyncSource {
private readonly props;
constructor(props: GithubSourceProps);
/**
* @internal
* @param accessPoint The EFS Access Point
*/
_createHandler(accessPoint: efs.AccessPoint): lambda.Function;
/**
* @internal
* @param id The task ID.
* @param accessPoint The EFS access point.
*/
_createFargateTask(id: string, accessPoint: efs.AccessPoint): FargateTaskConfig;
}
export declare class S3ArchiveSyncSource extends SyncSource {
private readonly props;
constructor(props: S3ArchiveSourceProps);
/**
* @internal
* @param accessPoint The EFS access point.
*/
_createHandler(accessPoint: efs.AccessPoint): lambda.Function;
/**
* @internal
* @param id The Fargate task ID.
* @param accessPoint The EFS access point.
*/
_createFargateTask(id: string, accessPoint: efs.AccessPoint): FargateTaskConfig;
}
export declare enum SyncEngine {
FARGATE = 0,
LAMBDA = 1
}
export interface SyncedAccessPointProps extends efs.AccessPointProps {
readonly syncSource: SyncSource;
/**
* The VPC to run the sync job
*/
readonly vpc: ec2.IVpc;
/**
* Trigger the sync with AWS Lambda or AWS Fargate.
*/
readonly engine?: SyncEngine;
}
export declare class SyncedAccessPoint extends efs.AccessPoint implements efs.IAccessPoint {
constructor(scope: Construct, id: string, props: SyncedAccessPointProps);
}