Skip to content

Commit cc0397b

Browse files
committed
Code review feedback
1 parent c8c50ff commit cc0397b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/aws-cdk-lib/aws-ecs/lib/ec2/ec2-service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,20 +267,22 @@ export class Ec2Service extends BaseService implements IEc2Service {
267267
* [Amazon ECS Task Placement Strategies](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html).
268268
*/
269269
@MethodMetadata()
270-
public addPlacementStrategies(...strategies: PlacementStrategy[]) {
271-
if (strategies.length > 0 && this.daemon) {
270+
public addPlacementStrategies(...newStrategies: PlacementStrategy[]) {
271+
if (newStrategies.length > 0 && this.daemon) {
272272
throw new ValidationError("Can't configure placement strategies when daemon=true", this);
273273
}
274274

275-
if (strategies.length > 0 && !this.strategies && this.availabilityZoneRebalancingEnabled) {
276-
const [placement] = strategies[0].toJson();
275+
if (newStrategies.length > 0 && !this.strategies && this.availabilityZoneRebalancingEnabled) {
276+
const [placement] = newStrategies[0].toJson();
277277
if (placement.type !== 'spread' || placement.field !== BuiltInAttributes.AVAILABILITY_ZONE) {
278278
throw new ValidationError(`AvailabilityZoneBalancing.ENABLED requires that the first placement strategy, if any, be 'spread across "${BuiltInAttributes.AVAILABILITY_ZONE}"'`, this);
279279
}
280280
}
281281

282-
this.strategies = [];
283-
for (const strategy of strategies) {
282+
if (!this.strategies) {
283+
this.strategies = [];
284+
}
285+
for (const strategy of newStrategies) {
284286
this.strategies.push(...strategy.toJson());
285287
}
286288
}

0 commit comments

Comments
 (0)