dcl-ops-lib 6.8.3 → 6.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -71,7 +71,7 @@ function getFargateExecutionRole(name, policyArnNamedMap) {
71
71
  // Default execution policy
72
72
  policies.push(new aws.iam.RolePolicyAttachment(`${name}-default-execution-policy`, {
73
73
  policyArn: "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy",
74
- role
74
+ role,
75
75
  }));
76
76
  Object.entries(policyArnNamedMap).forEach(([key, policyArn]) => {
77
77
  if (policyArn instanceof aws.iam.Policy) {
@@ -115,7 +115,7 @@ function getFargateTaskRole(name, policyArnNamedMap) {
115
115
  */
116
116
  function createFargateTask(serviceName, dockerImage, dockerListeningPort, environment, hostname, options) {
117
117
  return __awaiter(this, void 0, void 0, function* () {
118
- let { healthCheck, healthCheckContainer, essential, dontExpose, securityGroups, cluster, memoryReservation, command, version, ephemeralStorageInGB, desiredCount, cpuReservation, extraPortMappings, extraALBMappings, executionRolePolicies, taskRolePolicies, ignoreServiceDiscovery, secrets, metrics, dontAssignPublicIp, dependsOn, volumes, deregistrationDelay, mountPoints, repositoryCredentials, team, appAutoscaling } = options;
118
+ let { healthCheck, healthCheckContainer, essential, dontExpose, securityGroups, cluster, memoryReservation, command, version, ephemeralStorageInGB, desiredCount, cpuReservation, extraPortMappings, extraALBMappings, executionRolePolicies, taskRolePolicies, ignoreServiceDiscovery, secrets, metrics, dontAssignPublicIp, dependsOn, volumes, deregistrationDelay, mountPoints, repositoryCredentials, team, appAutoscaling, } = options;
119
119
  if (undefined === essential) {
120
120
  essential = true;
121
121
  }
@@ -155,7 +155,8 @@ function createFargateTask(serviceName, dockerImage, dockerListeningPort, enviro
155
155
  dependsOn.push(...policies);
156
156
  let dockerLabels = {};
157
157
  if (metrics && (metrics.port || dockerListeningPort)) {
158
- dockerLabels.ECS_PROMETHEUS_EXPORTER_PORT = "" + (metrics.port || dockerListeningPort);
158
+ dockerLabels.ECS_PROMETHEUS_EXPORTER_PORT =
159
+ "" + (metrics.port || dockerListeningPort);
159
160
  dockerLabels.ECS_PROMETHEUS_METRICS_PATH = metrics.path || "/metrics";
160
161
  if (metrics.jobName) {
161
162
  dockerLabels.ECS_PROMETHEUS_JOB_NAME = metrics.jobName;
@@ -188,7 +189,8 @@ function createFargateTask(serviceName, dockerImage, dockerListeningPort, enviro
188
189
  cidrBlocks: [vpc.cidrBlock],
189
190
  securityGroupId: taskSecurityGroup.id,
190
191
  });
191
- if (!extraPortMappings.find(($) => $.hostPort != metrics.port) && (port != dockerListeningPort || dontExpose)) {
192
+ if (!extraPortMappings.find(($) => $.hostPort != metrics.port) &&
193
+ (port != dockerListeningPort || dontExpose)) {
192
194
  extraPortMappings.push({
193
195
  containerPort: port,
194
196
  hostPort: port,
@@ -230,14 +232,14 @@ function createFargateTask(serviceName, dockerImage, dockerListeningPort, enviro
230
232
  portMappings: extraPortMappings,
231
233
  dockerLabels,
232
234
  mountPoints,
233
- repositoryCredentials
235
+ repositoryCredentials,
234
236
  },
235
237
  dependsOn,
236
238
  volumes,
237
239
  team,
238
240
  targetGroups,
239
241
  runtimePlatform: options.runtimePlatform,
240
- appAutoscaling
242
+ appAutoscaling,
241
243
  });
242
244
  return {
243
245
  service,
@@ -257,7 +259,10 @@ function createFargateTask(serviceName, dockerImage, dockerListeningPort, enviro
257
259
  });
258
260
  }
259
261
  }
260
- const portMapping = { containerPort: dockerListeningPort, hostPort: dockerListeningPort };
262
+ const portMapping = {
263
+ containerPort: dockerListeningPort,
264
+ hostPort: dockerListeningPort,
265
+ };
261
266
  // make the service accesible by the ALB
262
267
  (0, acceptAlb_1.makeSecurityGroupAccessibleFromSharedAlb)(taskSecurityGroup);
263
268
  const service = yield createInternalService({
@@ -284,14 +289,14 @@ function createFargateTask(serviceName, dockerImage, dockerListeningPort, enviro
284
289
  cpu: cpuReservation,
285
290
  dockerLabels,
286
291
  mountPoints,
287
- repositoryCredentials
292
+ repositoryCredentials,
288
293
  },
289
294
  dependsOn,
290
295
  volumes,
291
296
  team,
292
297
  targetGroups,
293
298
  runtimePlatform: options.runtimePlatform,
294
- appAutoscaling
299
+ appAutoscaling,
295
300
  });
296
301
  return { endpoint: `https://${hostname}/`, service, exposed };
297
302
  });
@@ -299,7 +304,7 @@ function createFargateTask(serviceName, dockerImage, dockerListeningPort, enviro
299
304
  function createInternalService(config) {
300
305
  return __awaiter(this, void 0, void 0, function* () {
301
306
  var _a, _b;
302
- let { serviceName, cluster, securityGroups, ignoreServiceDiscovery, serviceDiscoveryPort, desiredCount, executionRole, taskRole, containerInfo, assignPublicIp, dependsOn, volumes, team, targetGroups, runtimePlatform, ephemeralStorageInGB, appAutoscaling } = config;
307
+ let { serviceName, cluster, securityGroups, ignoreServiceDiscovery, serviceDiscoveryPort, desiredCount, executionRole, taskRole, containerInfo, assignPublicIp, dependsOn, volumes, team, targetGroups, runtimePlatform, ephemeralStorageInGB, appAutoscaling, } = config;
303
308
  if (!desiredCount)
304
309
  desiredCount = 1;
305
310
  assignPublicIp = !!assignPublicIp;
@@ -314,7 +319,7 @@ function createInternalService(config) {
314
319
  { type: "SRV", ttl: 10 },
315
320
  ],
316
321
  namespaceId: (0, supra_1.getInternalServiceDiscoveryNamespaceId)(),
317
- }
322
+ },
318
323
  });
319
324
  serviceRegistries = {
320
325
  port: serviceDiscoveryPort,
@@ -330,10 +335,14 @@ function createInternalService(config) {
330
335
  executionRoleArn: executionRole === null || executionRole === void 0 ? void 0 : executionRole.arn,
331
336
  taskRoleArn: taskRole === null || taskRole === void 0 ? void 0 : taskRole.arn,
332
337
  tags: { ServiceName: serviceName, Team: team },
333
- containerDefinitions: pulumi.jsonStringify([Object.assign(Object.assign({}, containerInfo), { logConfiguration: (0, exports.getDefaultLogs)(serviceName, logGroup) })]),
334
- ephemeralStorage: !!ephemeralStorageInGB ? {
335
- sizeInGib: ephemeralStorageInGB
336
- } : undefined,
338
+ containerDefinitions: pulumi.jsonStringify([
339
+ Object.assign(Object.assign({}, containerInfo), { logConfiguration: (0, exports.getDefaultLogs)(serviceName, logGroup) }),
340
+ ]),
341
+ ephemeralStorage: !!ephemeralStorageInGB
342
+ ? {
343
+ sizeInGib: ephemeralStorageInGB,
344
+ }
345
+ : undefined,
337
346
  cpu: (_a = containerInfo.cpu) === null || _a === void 0 ? void 0 : _a.toString(),
338
347
  memory: (_b = containerInfo.memoryReservation) === null || _b === void 0 ? void 0 : _b.toString(),
339
348
  runtimePlatform: runtimePlatform,
@@ -359,11 +368,11 @@ function createInternalService(config) {
359
368
  ...targetGroups.map((tg) => ({
360
369
  targetGroupArn: tg.arn,
361
370
  containerName: serviceName,
362
- containerPort: tg.port
363
- }))
364
- ]
371
+ containerPort: tg.port,
372
+ })),
373
+ ],
365
374
  }, Object.assign(Object.assign({}, extraOpts), { dependsOn }));
366
- console.log('Should set-up autoscaling', { should: !!appAutoscaling });
375
+ console.log("Should set-up autoscaling", { should: !!appAutoscaling });
367
376
  if (!!appAutoscaling) {
368
377
  setAutoscaling(service, Object.assign(Object.assign({}, appAutoscaling), { desiredCount }));
369
378
  }
@@ -373,42 +382,41 @@ function createInternalService(config) {
373
382
  function setAutoscaling(service, config) {
374
383
  const taskUniqueIdentifier = `${service.name}-${domain_1.env}`;
375
384
  // resolve the Output<string> before using it
376
- config.metricDimensionValue.apply(metricValue => {
377
- const ecsTarget = new aws.appautoscaling.Target(`ecs-target-${taskUniqueIdentifier}`, {
378
- maxCapacity: config.maxCapacity,
379
- minCapacity: config.desiredCount,
380
- resourceId: pulumi.interpolate `service/${service.cluster}/${service.name}`,
381
- scalableDimension: "ecs:service:DesiredCount",
382
- serviceNamespace: "ecs",
383
- });
384
- const CSM_ApproximateNumberOfMessagesVisible = {
385
- metricName: config.metricName,
386
- namespace: "AWS/SQS",
387
- dimensions: [
388
- {
389
- name: "QueueName",
390
- value: metricValue,
391
- },
392
- ],
393
- statistic: config.statistic,
394
- unit: "Count",
395
- };
396
- let TTS_CustomizedMetricSpecification = undefined;
397
- if (config.metricName === "ApproximateNumberOfMessagesVisible") {
398
- TTS_CustomizedMetricSpecification = CSM_ApproximateNumberOfMessagesVisible;
399
- }
400
- return new aws.appautoscaling.Policy(`ecs-autoscaling-policy-${taskUniqueIdentifier}`, {
401
- policyType: "TargetTrackingScaling",
402
- resourceId: ecsTarget.resourceId,
403
- scalableDimension: ecsTarget.scalableDimension,
404
- serviceNamespace: ecsTarget.serviceNamespace,
405
- targetTrackingScalingPolicyConfiguration: {
406
- targetValue: config.targetValue,
407
- customizedMetricSpecification: TTS_CustomizedMetricSpecification,
408
- scaleOutCooldown: config.scaleOutCooldown,
409
- scaleInCooldown: config.scaleInCooldown,
410
- },
411
- }, { dependsOn: [ecsTarget] });
385
+ const stringifiedMetricDimensionValue = config.metricDimensionValue;
386
+ const ecsTarget = new aws.appautoscaling.Target(`ecs-target-${taskUniqueIdentifier}`, {
387
+ maxCapacity: config.maxCapacity,
388
+ minCapacity: config.desiredCount,
389
+ resourceId: pulumi.interpolate `service/${service.cluster}/${service.name}`,
390
+ scalableDimension: "ecs:service:DesiredCount",
391
+ serviceNamespace: "ecs",
412
392
  });
393
+ const CSM_ApproximateNumberOfMessagesVisible = {
394
+ metricName: config.metricName,
395
+ namespace: "AWS/SQS",
396
+ dimensions: [
397
+ {
398
+ name: "QueueName",
399
+ value: stringifiedMetricDimensionValue,
400
+ },
401
+ ],
402
+ statistic: config.statistic,
403
+ unit: "Count",
404
+ };
405
+ let TTS_CustomizedMetricSpecification = undefined;
406
+ if (config.metricName === "ApproximateNumberOfMessagesVisible") {
407
+ TTS_CustomizedMetricSpecification = CSM_ApproximateNumberOfMessagesVisible;
408
+ }
409
+ return new aws.appautoscaling.Policy(`ecs-autoscaling-policy-${taskUniqueIdentifier}`, {
410
+ policyType: "TargetTrackingScaling",
411
+ resourceId: ecsTarget.resourceId,
412
+ scalableDimension: ecsTarget.scalableDimension,
413
+ serviceNamespace: ecsTarget.serviceNamespace,
414
+ targetTrackingScalingPolicyConfiguration: {
415
+ targetValue: config.targetValue,
416
+ customizedMetricSpecification: TTS_CustomizedMetricSpecification,
417
+ scaleOutCooldown: config.scaleOutCooldown,
418
+ scaleInCooldown: config.scaleInCooldown,
419
+ },
420
+ }, { dependsOn: [ecsTarget] });
413
421
  }
414
422
  //# sourceMappingURL=createFargateTask.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcl-ops-lib",
3
- "version": "6.8.3",
3
+ "version": "6.8.4",
4
4
  "scripts": {
5
5
  "build": "tsc && cp bin/* . && node test.js",
6
6
  "clean": "rm *.d.ts *.js *.js.map"