Skip to content

Commit

Permalink
WIP: cluster support
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hammond committed Feb 10, 2020
1 parent c18217d commit 1b9a8ea
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface EcsDeployActionProps extends codepipeline.CommonAwsActionProps
/**
* The ECS Service to deploy.
*/
readonly service: ecs.BaseService;
readonly service: ecs.IBaseService;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface IService extends IResource {
* @attribute
*/
readonly serviceName: string;

}

export interface IBaseService extends IService {
readonly cluster: ICluster;
}

/**
Expand Down
22 changes: 21 additions & 1 deletion packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import { Construct, Lazy, Resource, Stack } from '@aws-cdk/core';
import { BaseService, BaseServiceOptions, IService, LaunchType, PropagatedTagSource } from '../base/base-service';
import {
BaseService,
BaseServiceOptions,
IBaseService,
IService,
LaunchType,
PropagatedTagSource
} from '../base/base-service';
import { NetworkMode, TaskDefinition } from '../base/task-definition';
import { CfnService } from '../ecs.generated';
import { PlacementConstraint, PlacementStrategy } from '../placement';
Expand Down Expand Up @@ -111,6 +118,19 @@ export class Ec2Service extends BaseService implements IEc2Service {
return new Import(scope, id);
}

/**
* Import a service definition from the specified service attributes.
*/
public static fromEc2ServiceAttributes(scope: Construct, id: string, attributes: string): IBaseService {
class Import extends Resource implements IBaseService {
public readonly cluster = ;
public readonly serviceArn = fargateServiceArn;
public readonly serviceName = matcher.exec(fargateServiceArn)[0];
}
return new Import(scope, id)
}


private readonly constraints: CfnService.PlacementConstraintProperty[];
private readonly strategies: CfnService.PlacementStrategyProperty[];
private readonly daemon: boolean;
Expand Down
23 changes: 22 additions & 1 deletion packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import { BaseService, BaseServiceOptions, IService, LaunchType, PropagatedTagSource } from '../base/base-service';
import {
BaseService,
BaseServiceOptions,
IBaseService,
IService,
LaunchType,
PropagatedTagSource
} from '../base/base-service';
import { TaskDefinition } from '../base/task-definition';

/**
Expand Down Expand Up @@ -87,6 +94,20 @@ export class FargateService extends BaseService implements IFargateService {
return new Import(scope, id);
}

/**
* Import a service definition from the specified service attributes.
*/
public static fromFargateServiceAttributes(scope: cdk.Construct, id: string, attributes: string): IBaseService {
const matcher = new RegExp(/arn:[^:]+:ecs:[^:]+[^:]+:[^:]+:service\/(.*)/);
class Import extends cdk.Resource implements IBaseService {
public readonly cluster = ;
public readonly serviceArn = fargateServiceArn;
public readonly serviceName = matcher.exec(fargateServiceArn)[0];
}
return new Import(scope, id);
}


/**
* Constructs a new instance of the FargateService class.
*/
Expand Down

0 comments on commit 1b9a8ea

Please sign in to comment.