aws-delivlib
Version:
A fabulous library for defining continuous pipelines for building, testing and releasing code libraries.
89 lines (88 loc) • 3.02 kB
TypeScript
import { IAspect, aws_ecr as ecr, aws_codebuild as codebuild, aws_events as events, aws_secretsmanager as sm } from 'aws-cdk-lib';
import { Construct, IConstruct } from 'constructs';
import { MirrorSource } from './mirror-source';
/**
* Authentication details for DockerHub.
*
* @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.secrets-manager
*/
export interface DockerHubCredentials {
/**
* The secret that contains the username and password for Dockerhub
*/
readonly secret: sm.ISecret;
/**
* The secret key that contains the username in the specified secret.
*/
readonly usernameKey: string;
/**
* The secret key that contains the password in the specified secret.
*/
readonly passwordKey: string;
/**
* Version stage of the secret.
*
* @default 'AWSCURRENT'
*/
readonly versionStage?: string;
}
/**
* Properties to initialize EcrRegistrySync
*/
export interface EcrMirrorProps {
/**
* The list of images to keep sync'ed.
*/
readonly sources: MirrorSource[];
/**
* Credentials to signing into Dockerhub.
*/
readonly dockerHubCredentials: DockerHubCredentials;
/**
* The image used to run the mirror step itself.
*
* Prefer to supply the image yourself here.
*
* @default - Some superchain image that may grow outdated.
*/
readonly buildImage?: codebuild.IBuildImage;
/**
* Sync job runs on a schedule.
* Throws an error if neither this nor `autoStart` are specified.
* @default - does not run on schedule
*/
readonly schedule?: events.Schedule;
/**
* Start the sync job immediately after the deployment.
* This injects a custom resource that is executed as part of the deployment.
* Throws an error if neither this nor `schedule` are specified.
* @default false
*/
readonly autoStart?: boolean;
}
/**
* Synchronize images from DockerHub to an ECR registry in the AWS account.
* This is particularly useful to workaround DockerHub's throttling on pulls and use ECR instead.
*/
export declare class EcrMirror extends Construct {
private readonly _repos;
private readonly _repoTagsSeen;
readonly project: codebuild.Project;
constructor(scope: Construct, id: string, props: EcrMirrorProps);
private createMirrorRepo;
/**
* Get the target ECR repository for the given repository name and tag.
* @param repositoryName The ECR repository with this name
* @param tag the tag for the repository, defaults to 'latest'
*/
ecrRepository(repositoryName: string): ecr.IRepository | undefined;
}
/**
* An aspect that walks through the construct tree and replaces CodeBuild jobs with Docker images
* with ECR equivalents found in the EcrMirror.
*/
export declare class EcrMirrorAspect implements IAspect {
private readonly mirror;
constructor(mirror: EcrMirror);
visit(construct: IConstruct): void;
}