@gradientedge/cdk-utils 7.8.0 → 7.9.1

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.
@@ -24,9 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.SiteWithEcsBackend = void 0;
27
+ const cdk = __importStar(require("aws-cdk-lib"));
27
28
  const cloudfront = __importStar(require("aws-cdk-lib/aws-cloudfront"));
28
29
  const origins = __importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
29
30
  const ecs = __importStar(require("aws-cdk-lib/aws-ecs"));
31
+ const ecsPatterns = __importStar(require("aws-cdk-lib/aws-ecs-patterns"));
30
32
  const iam = __importStar(require("aws-cdk-lib/aws-iam"));
31
33
  const common_1 = require("../../common");
32
34
  /**
@@ -219,22 +221,47 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
219
221
  * @protected
220
222
  */
221
223
  createEcsService() {
222
- const fargateService = this.ecsManager.createLoadBalancedFargateService(this.id, this, {
223
- ...this.props.siteTask,
224
- ...{
225
- domainName: this.siteInternalDomainName,
226
- domainZone: this.siteHostedZone,
227
- healthCheck: this.props.siteHealthCheck,
228
- taskImageOptions: {
229
- ...this.props.siteTask.taskImageOptions,
230
- environment: this.siteEcsEnvironment,
231
- executionRole: this.siteEcsRole,
232
- taskRole: this.siteEcsRole,
233
- image: this.siteEcsContainerImage,
234
- secrets: this.siteSecrets,
235
- },
224
+ const fargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, `${this.id}-ecs-service`, {
225
+ cluster: this.siteEcsCluster,
226
+ desiredCount: this.props.siteTask.desiredCount,
227
+ enableECSManagedTags: true,
228
+ serviceName: `${this.id}-${this.props.stage}`,
229
+ cpu: this.props.siteTask.cpu,
230
+ loadBalancerName: `${this.id}-${this.props.stage}`,
231
+ domainName: this.siteInternalDomainName,
232
+ domainZone: this.siteHostedZone,
233
+ listenerPort: this.props.siteTask.listenerPort,
234
+ memoryLimitMiB: this.props.siteTask.memoryLimitMiB,
235
+ healthCheckGracePeriod: cdk.Duration.seconds(60),
236
+ assignPublicIp: true,
237
+ taskImageOptions: {
238
+ enableLogging: true,
239
+ logDriver: ecs.LogDriver.awsLogs({
240
+ logGroup: this.siteEcsLogGroup,
241
+ streamPrefix: `${this.id}-${this.props.stage}/ecs`,
242
+ }),
243
+ image: this.siteEcsContainerImage,
244
+ executionRole: this.siteEcsRole,
245
+ taskRole: this.siteEcsRole,
246
+ containerPort: this.props.siteTask.taskImageOptions?.containerPort,
247
+ environment: this.siteEcsEnvironment,
248
+ secrets: this.siteSecrets,
236
249
  },
237
- }, this.siteEcsCluster, this.siteEcsLogGroup);
250
+ });
251
+ if (this.props.siteHealthCheck) {
252
+ fargateService.targetGroup.configureHealthCheck({
253
+ enabled: this.props.siteHealthCheck.enabled ?? true,
254
+ path: this.props.siteHealthCheck.path ?? '/',
255
+ port: this.props.siteHealthCheck.port,
256
+ interval: cdk.Duration.seconds(this.props.siteHealthCheck.intervalInSecs),
257
+ timeout: cdk.Duration.seconds(this.props.siteHealthCheck.timeoutInSecs),
258
+ healthyThresholdCount: this.props.siteHealthCheck.healthyThresholdCount,
259
+ unhealthyThresholdCount: this.props.siteHealthCheck.unhealthyThresholdCount,
260
+ healthyGrpcCodes: this.props.siteHealthCheck.healthyGrpcCodes,
261
+ healthyHttpCodes: this.props.siteHealthCheck.healthyHttpCodes,
262
+ protocol: this.props.siteHealthCheck.protocol,
263
+ });
264
+ }
238
265
  this.siteEcsService = fargateService.service;
239
266
  this.siteEcsTaskDefinition = fargateService.taskDefinition;
240
267
  this.siteEcsListener = fargateService.listener;
@@ -102,7 +102,7 @@ class EcsManager {
102
102
  proxyConfiguration: props.proxyConfiguration,
103
103
  runtimePlatform: {
104
104
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? ecs.OperatingSystemFamily.LINUX,
105
- cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.ARM64,
105
+ cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.X86_64,
106
106
  },
107
107
  taskRole: role,
108
108
  volumes: props.volumes,
@@ -151,7 +151,7 @@ class EcsManager {
151
151
  memoryLimitMiB: props.memoryLimitMiB,
152
152
  runtimePlatform: {
153
153
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? ecs.OperatingSystemFamily.LINUX,
154
- cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.ARM64,
154
+ cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.X86_64,
155
155
  },
156
156
  serviceName: `${id}-${scope.props.stage}`,
157
157
  taskImageOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "7.8.0",
3
+ "version": "7.9.1",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -1,8 +1,10 @@
1
+ import * as cdk from 'aws-cdk-lib'
1
2
  import * as certificateManager from 'aws-cdk-lib/aws-certificatemanager'
2
3
  import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
3
4
  import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'
4
5
  import * as ec2 from 'aws-cdk-lib/aws-ec2'
5
6
  import * as ecs from 'aws-cdk-lib/aws-ecs'
7
+ import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns'
6
8
  import * as elb from 'aws-cdk-lib/aws-elasticloadbalancingv2'
7
9
  import * as iam from 'aws-cdk-lib/aws-iam'
8
10
  import * as logs from 'aws-cdk-lib/aws-logs'
@@ -241,28 +243,48 @@ export class SiteWithEcsBackend extends CommonConstruct {
241
243
  * @protected
242
244
  */
243
245
  protected createEcsService() {
244
- const fargateService = this.ecsManager.createLoadBalancedFargateService(
245
- this.id,
246
- this,
247
- {
248
- ...this.props.siteTask,
249
- ...{
250
- domainName: this.siteInternalDomainName,
251
- domainZone: this.siteHostedZone,
252
- healthCheck: this.props.siteHealthCheck,
253
- taskImageOptions: {
254
- ...this.props.siteTask.taskImageOptions,
255
- environment: this.siteEcsEnvironment,
256
- executionRole: this.siteEcsRole,
257
- taskRole: this.siteEcsRole,
258
- image: this.siteEcsContainerImage,
259
- secrets: this.siteSecrets,
260
- },
261
- },
246
+ const fargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, `${this.id}-ecs-service`, {
247
+ cluster: this.siteEcsCluster,
248
+ desiredCount: this.props.siteTask.desiredCount,
249
+ enableECSManagedTags: true,
250
+ serviceName: `${this.id}-${this.props.stage}`,
251
+ cpu: this.props.siteTask.cpu,
252
+ loadBalancerName: `${this.id}-${this.props.stage}`,
253
+ domainName: this.siteInternalDomainName,
254
+ domainZone: this.siteHostedZone,
255
+ listenerPort: this.props.siteTask.listenerPort,
256
+ memoryLimitMiB: this.props.siteTask.memoryLimitMiB,
257
+ healthCheckGracePeriod: cdk.Duration.seconds(60),
258
+ assignPublicIp: true,
259
+ taskImageOptions: {
260
+ enableLogging: true,
261
+ logDriver: ecs.LogDriver.awsLogs({
262
+ logGroup: this.siteEcsLogGroup,
263
+ streamPrefix: `${this.id}-${this.props.stage}/ecs`,
264
+ }),
265
+ image: this.siteEcsContainerImage,
266
+ executionRole: this.siteEcsRole,
267
+ taskRole: this.siteEcsRole,
268
+ containerPort: this.props.siteTask.taskImageOptions?.containerPort,
269
+ environment: this.siteEcsEnvironment,
270
+ secrets: this.siteSecrets,
262
271
  },
263
- this.siteEcsCluster,
264
- this.siteEcsLogGroup
265
- )
272
+ })
273
+
274
+ if (this.props.siteHealthCheck) {
275
+ fargateService.targetGroup.configureHealthCheck({
276
+ enabled: this.props.siteHealthCheck.enabled ?? true,
277
+ path: this.props.siteHealthCheck.path ?? '/',
278
+ port: this.props.siteHealthCheck.port,
279
+ interval: cdk.Duration.seconds(this.props.siteHealthCheck.intervalInSecs),
280
+ timeout: cdk.Duration.seconds(this.props.siteHealthCheck.timeoutInSecs),
281
+ healthyThresholdCount: this.props.siteHealthCheck.healthyThresholdCount,
282
+ unhealthyThresholdCount: this.props.siteHealthCheck.unhealthyThresholdCount,
283
+ healthyGrpcCodes: this.props.siteHealthCheck.healthyGrpcCodes,
284
+ healthyHttpCodes: this.props.siteHealthCheck.healthyHttpCodes,
285
+ protocol: this.props.siteHealthCheck.protocol,
286
+ })
287
+ }
266
288
 
267
289
  this.siteEcsService = fargateService.service
268
290
  this.siteEcsTaskDefinition = fargateService.taskDefinition
@@ -95,7 +95,7 @@ export class EcsManager {
95
95
  proxyConfiguration: props.proxyConfiguration,
96
96
  runtimePlatform: {
97
97
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? ecs.OperatingSystemFamily.LINUX,
98
- cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.ARM64,
98
+ cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.X86_64,
99
99
  },
100
100
  taskRole: role,
101
101
  volumes: props.volumes,
@@ -153,7 +153,7 @@ export class EcsManager {
153
153
  memoryLimitMiB: props.memoryLimitMiB,
154
154
  runtimePlatform: {
155
155
  operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? ecs.OperatingSystemFamily.LINUX,
156
- cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.ARM64,
156
+ cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.X86_64,
157
157
  },
158
158
  serviceName: `${id}-${scope.props.stage}`,
159
159
  taskImageOptions: {