dcl-ops-lib 6.4.0 → 6.6.0

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.
@@ -31,4 +31,5 @@ export type StaticWebsite = {
31
31
  priceClass?: "PriceClass_All" | "PriceClass_200" | "PriceClass_100";
32
32
  cachePolicyId?: Input<string>;
33
33
  objectOwnership?: string;
34
+ overrideContentBucketACL?: string;
34
35
  };
package/buildStatic.js CHANGED
@@ -23,7 +23,7 @@ function buildStatic(staticSite) {
23
23
  const slug = staticSite.domain.replace(/\./g, "-") + "-";
24
24
  // contentBucket is the S3 bucket that the website's contents will be stored in.
25
25
  const bucketInfo = {
26
- acl: "public-read",
26
+ acl: staticSite.overrideContentBucketACL ? staticSite.overrideContentBucketACL : "public-read",
27
27
  // Configure S3 to serve bucket contents as a website. This way S3 will automatically convert
28
28
  // requests for "foo/" to "foo/index.html".
29
29
  website: {
@@ -53,6 +53,15 @@ export type FargateTaskOptions = {
53
53
  mountPoints?: aws.ecs.MountPoint[];
54
54
  repositoryCredentials?: aws.ecs.RepositoryCredentials;
55
55
  runtimePlatform?: aws.types.input.ecs.TaskDefinitionRuntimePlatform;
56
+ appAutoscaling?: {
57
+ maxCapacity: number;
58
+ metricName: string;
59
+ targetValue: number;
60
+ metricDimensionName: string;
61
+ statistic?: "Average" | "Minimum" | "Maximum";
62
+ scaleOutCooldown?: number;
63
+ scaleInCooldown?: number;
64
+ };
56
65
  };
57
66
  /**
58
67
  *
@@ -65,6 +74,7 @@ export type FargateTaskOptions = {
65
74
  * @param options.cluster The cluster where to run this. If none is provided, the `defaultCluster` will be used ({@see infra/defaultCluster.ts})
66
75
  * @param options.healthCheckPath
67
76
  * @param options.policyArnNamedMap key-value named map of policies to attach to the default execution role for this task
77
+ * @param options.appAutoscaling Configuration for autoscaling
68
78
  */
69
79
  export declare function createFargateTask(serviceName: string, dockerImage: string | Promise<string> | pulumi.OutputInstance<string>, dockerListeningPort: number, environment: {
70
80
  name: string;
@@ -101,5 +111,14 @@ export type InternalServiceOptions = {
101
111
  team: string;
102
112
  targetGroups: aws.alb.TargetGroup[];
103
113
  runtimePlatform?: aws.types.input.ecs.TaskDefinitionRuntimePlatform;
114
+ appAutoscaling?: {
115
+ maxCapacity: number;
116
+ metricName: string;
117
+ targetValue: number;
118
+ metricDimensionName: string;
119
+ statistic?: "Average" | "Minimum" | "Maximum";
120
+ scaleOutCooldown?: number;
121
+ scaleInCooldown?: number;
122
+ };
104
123
  };
105
124
  export declare function createInternalService(config: InternalServiceOptions): Promise<import("@pulumi/aws/ecs/service").Service>;
@@ -111,6 +111,7 @@ function getFargateTaskRole(name, policyArnNamedMap) {
111
111
  * @param options.cluster The cluster where to run this. If none is provided, the `defaultCluster` will be used ({@see infra/defaultCluster.ts})
112
112
  * @param options.healthCheckPath
113
113
  * @param options.policyArnNamedMap key-value named map of policies to attach to the default execution role for this task
114
+ * @param options.appAutoscaling Configuration for autoscaling
114
115
  */
115
116
  function createFargateTask(serviceName, dockerImage, dockerListeningPort, environment, hostname, options) {
116
117
  return __awaiter(this, void 0, void 0, function* () {
@@ -334,7 +335,7 @@ function createInternalService(config) {
334
335
  volumes: volumes,
335
336
  family: (0, stack_1.getStackScopedName)(serviceName),
336
337
  }, { dependsOn: [logGroup] });
337
- return new aws.ecs.Service((0, stack_1.getStackScopedName)(serviceName), {
338
+ const service = new aws.ecs.Service((0, stack_1.getStackScopedName)(serviceName), {
338
339
  cluster: yield getClusterInstance(cluster),
339
340
  tags: { ServiceName: serviceName, StackId: (0, stack_1.getStackId)(), Team: team },
340
341
  networkConfiguration: {
@@ -355,6 +356,48 @@ function createInternalService(config) {
355
356
  }))
356
357
  ]
357
358
  }, Object.assign(Object.assign({}, extraOpts), { dependsOn }));
359
+ if (!!config.appAutoscaling) {
360
+ setAutoscaling(service, Object.assign(Object.assign({}, config.appAutoscaling), { desiredCount }));
361
+ }
362
+ return service;
363
+ });
364
+ }
365
+ function setAutoscaling(service, config) {
366
+ const taskUniqueIdentifier = `${service.name}-${domain_1.env}`;
367
+ const ecsTarget = new aws.appautoscaling.Target(`ecs-target-${taskUniqueIdentifier}`, {
368
+ maxCapacity: config.maxCapacity,
369
+ minCapacity: config.desiredCount,
370
+ resourceId: `service/${service.cluster}/${service.name}`,
371
+ scalableDimension: "ecs:service:DesiredCount",
372
+ serviceNamespace: "ecs",
373
+ });
374
+ const CSM_ApproximateNumberOfMessagesVisible = {
375
+ metricName: config.metricName,
376
+ namespace: "AWS/SQS",
377
+ dimensions: [
378
+ {
379
+ name: "QueueName",
380
+ value: config.metricDimensionName
381
+ },
382
+ ],
383
+ statistic: config.statistic,
384
+ unit: "Count",
385
+ };
386
+ let TTS_CustomizedMetricSpecification = undefined;
387
+ if (config.metricName === "ApproximateNumberOfMessagesVisible") {
388
+ TTS_CustomizedMetricSpecification = CSM_ApproximateNumberOfMessagesVisible;
389
+ }
390
+ new aws.appautoscaling.Policy(`ecs-autoscaling-policy-${taskUniqueIdentifier}`, {
391
+ policyType: "TargetTrackingScaling",
392
+ resourceId: ecsTarget.resourceId,
393
+ scalableDimension: ecsTarget.scalableDimension,
394
+ serviceNamespace: ecsTarget.serviceNamespace,
395
+ targetTrackingScalingPolicyConfiguration: {
396
+ targetValue: config.targetValue,
397
+ customizedMetricSpecification: TTS_CustomizedMetricSpecification,
398
+ scaleOutCooldown: config.scaleOutCooldown,
399
+ scaleInCooldown: config.scaleInCooldown,
400
+ },
358
401
  });
359
402
  }
360
403
  //# sourceMappingURL=createFargateTask.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcl-ops-lib",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "scripts": {
5
5
  "build": "tsc && cp bin/* . && node test.js",
6
6
  "clean": "rm *.d.ts *.js *.js.map"