Skip to content

Commit

Permalink
fix(aws-ecs): make cluster name private in all services
Browse files Browse the repository at this point in the history
  • Loading branch information
piradeepk committed Jun 21, 2019
1 parent 67f6de0 commit 6a9045b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
9 changes: 2 additions & 7 deletions packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ export abstract class BaseService extends Resource
*/
public readonly serviceName: string;

/**
* Name of this service's cluster
*/
public readonly clusterName: string;

/**
* Task definition this service is associated with
*/
Expand All @@ -129,14 +124,14 @@ export abstract class BaseService extends Resource
protected networkConfiguration?: CfnService.NetworkConfigurationProperty;
protected serviceRegistries = new Array<CfnService.ServiceRegistryProperty>();

private readonly clusterName: string;
private readonly resource: CfnService;
private scalableTaskCount?: ScalableTaskCount;

constructor(scope: Construct,
id: string,
props: BaseServiceProps,
additionalProps: any,
clusterName: string,
taskDefinition: TaskDefinition) {
super(scope, id, {
physicalName: props.serviceName,
Expand Down Expand Up @@ -178,7 +173,7 @@ export abstract class BaseService extends Resource
this.serviceArn = resourceIdentifiers.arn;
this.serviceName = resourceIdentifiers.name;

this.clusterName = clusterName;
this.clusterName = props.cluster.clusterName;
this.cluster = props.cluster;

if (props.serviceDiscoveryOptions) {
Expand Down
8 changes: 1 addition & 7 deletions packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ export class Ec2Service extends BaseService implements IEc2Service, elb.ILoadBal
return new Import(scope, id);
}

/**
* Name of the cluster
*/
public readonly clusterName: string;

private readonly constraints: CfnService.PlacementConstraintProperty[];
private readonly strategies: CfnService.PlacementStrategyProperty[];
private readonly daemon: boolean;
Expand Down Expand Up @@ -125,9 +120,8 @@ export class Ec2Service extends BaseService implements IEc2Service, elb.ILoadBal
placementConstraints: Lazy.anyValue({ produce: () => this.constraints }, { omitEmptyArray: true }),
placementStrategies: Lazy.anyValue({ produce: () => this.strategies }, { omitEmptyArray: true }),
schedulingStrategy: props.daemon ? 'DAEMON' : 'REPLICA',
}, props.cluster.clusterName, props.taskDefinition);
}, props.taskDefinition);

this.clusterName = props.cluster.clusterName;
this.constraints = [];
this.strategies = [];
this.daemon = props.daemon || false;
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class FargateService extends BaseService implements IFargateService {
taskDefinition: props.taskDefinition.taskDefinitionArn,
launchType: 'FARGATE',
platformVersion: props.platformVersion,
}, props.cluster.clusterName, props.taskDefinition);
}, props.taskDefinition);

this.configureAwsVpcNetworking(props.cluster.vpc, props.assignPublicIp, props.vpcSubnets, props.securityGroup);

Expand Down

0 comments on commit 6a9045b

Please sign in to comment.