@@ -114,17 +114,16 @@ export abstract class BaseService extends Resource
114114 public readonly serviceName : string ;
115115
116116 /**
117- * Name of this service's cluster
117+ * Task definition this service is associated with
118118 */
119- public readonly clusterName : string ;
119+ public readonly taskDefinition : TaskDefinition ;
120120
121121 /**
122- * Task definition this service is associated with
122+ * The cluster this service is scheduled on
123123 */
124- public readonly taskDefinition : TaskDefinition ;
124+ public readonly cluster : ICluster ;
125125
126126 protected cloudmapService ?: cloudmap . Service ;
127- protected cluster : ICluster ;
128127 protected loadBalancers = new Array < CfnService . LoadBalancerProperty > ( ) ;
129128 protected networkConfiguration ?: CfnService . NetworkConfigurationProperty ;
130129 protected serviceRegistries = new Array < CfnService . ServiceRegistryProperty > ( ) ;
@@ -136,7 +135,6 @@ export abstract class BaseService extends Resource
136135 id : string ,
137136 props : BaseServiceProps ,
138137 additionalProps : any ,
139- clusterName : string ,
140138 taskDefinition : TaskDefinition ) {
141139 super ( scope , id , {
142140 physicalName : props . serviceName ,
@@ -178,7 +176,6 @@ export abstract class BaseService extends Resource
178176 this . serviceArn = resourceIdentifiers . arn ;
179177 this . serviceName = resourceIdentifiers . name ;
180178
181- this . clusterName = clusterName ;
182179 this . cluster = props . cluster ;
183180
184181 if ( props . serviceDiscoveryOptions ) {
@@ -224,7 +221,7 @@ export abstract class BaseService extends Resource
224221
225222 return this . scalableTaskCount = new ScalableTaskCount ( this , 'TaskCount' , {
226223 serviceNamespace : appscaling . ServiceNamespace . ECS ,
227- resourceId : `service/${ this . clusterName } /${ this . serviceName } ` ,
224+ resourceId : `service/${ this . cluster . clusterName } /${ this . serviceName } ` ,
228225 dimension : 'ecs:service:DesiredCount' ,
229226 role : this . makeAutoScalingRole ( ) ,
230227 ...props
@@ -238,7 +235,7 @@ export abstract class BaseService extends Resource
238235 return new cloudwatch . Metric ( {
239236 namespace : 'AWS/ECS' ,
240237 metricName,
241- dimensions : { ClusterName : this . clusterName , ServiceName : this . serviceName } ,
238+ dimensions : { ClusterName : this . cluster . clusterName , ServiceName : this . serviceName } ,
242239 ...props
243240 } ) ;
244241 }
0 commit comments