import * as ecs from '@aws-cdk/aws-ecs' ; import * as cdk from '@aws-cdk/core' ; import { Service , ConnectToProps } from '../service' ; import { Construct } from '@aws-cdk/core' ; /**
 * The types of capacity that are supported. These capacity types may change the
 * behavior of an extension.
 */ export enum EnvironmentCapacityType { /**
     * Specify that the environment should use AWS Fargate for
     * hosting containers.
     */ FARGATE = 'fargate' , /**
     * Specify that the environment should launch containers onto
     * EC2 instances.
     */ EC2 = 'ec2' } /**
 * A set of mutable service props in the process of being assembled using a
 * builder pattern. They will eventually to be translated into an
 * ecs.Ec2ServiceProps or ecs.FargateServiceProps interface, depending on the
 * environment's capacity type.
 */ export interface ServiceBuild { /**
     * The cluster in which to launch the service.
     */ readonly cluster : ecs . ICluster ; /**
     * The task definition registered to this service.
     */ readonly taskDefinition : ecs . TaskDefinition ; default readonly assignPublicIp ? : boolean ; default readonly cloudMapOptions ? : ecs . CloudMapOptions ; default readonly healthCheckGracePeriod ? : cdk . Duration ; default readonly desiredCount ? : number ; default readonly minHealthyPercent ? : number ; default readonly maxHealthyPercent ? : number ; } /**
 * The shape of a service extension. This abstract class is implemented
 * by other extensions that extend the hooks to implement any custom
 * logic that they want to run during each step of preparing the service.
 */ export abstract class ServiceExtension { /**
     * The name of the extension.
     */ public name : string ; /**
     * The container for this extension. Most extensions have a container, but not
     * every extension is required to have a container. Some extensions may just
     * modify the properties of the service, or create external resources
     * connected to the service.
     */ public container ? : ecs . ContainerDefinition ; /**
     * The service which this extension is being added to.
     * Initially, extensions are collected into a ServiceDescription, but no service
     * exists yet. Later, when the ServiceDescription is used to create a service,
     * the extension is told what Service it is now working on.
     */ protected parentService ! : Service ; protected scope ! : cdk . Construct ; protected containerMutatingHooks : ContainerMutatingHook [ ] = [ ] ; constructor ( name ) { this . name = name ; } /**
     * A hook that allows the extension to add hooks to other
     * extensions that are registered.
     */ public addHooks ( ) { } param hook public addContainerMutatingHook ( hook ) { this . containerMutatingHooks . push ( hook ) ; } param props public modifyTaskDefinitionProps ( props ) { return { ... props , } as ecs . TaskDefinitionProps ; } param parent param scope public prehook ( parent , scope ) { this . parentService = parent ; this . scope = scope ; } param taskDefinition public useTaskDefinition ( taskDefinition ) { taskDefinition = taskDefinition ; } /**
     * Once all containers are added to the task definition, this hook is
     * called for each extension to give it a chance to resolve its dependency
     * graph so that its container starts in the right order based on the
     * other extensions that were enabled.
     */ public resolveContainerDependencies ( ) { return ; } param props public modifyServiceProps ( props ) { return { ... props , } as ServiceBuild ; } param service public useService ( service ) { service = service ; } param service public connectToService ( service , connectToProps ) { service = service ; connectToProps = connectToProps ; } } /**
 * This is an abstract class wrapper for a mutating hook. It is
 * extended by any extension which wants to mutate other extension's containers.
 */ export abstract class ContainerMutatingHook { param props public mutateContainerDefinition ( props ) { return { ... props , } as ecs . ContainerDefinitionOptions ; } }