@@ -43,7 +43,7 @@ import { StringParameter } from 'aws-cdk-lib/aws-ssm';
43
43
import { Construct } from 'constructs' ;
44
44
45
45
import { createCdkId } from '../../../lib/core/utils' ;
46
- import { BaseProps , AmiHardwareType , EcsSourceType } from '../../../lib/schema' ;
46
+ import { AmiHardwareType , EcsSourceType , PartialConfig } from '../../../lib/schema' ;
47
47
import { Ec2Metadata , ECSConfig } from '../../../lib/schema' ;
48
48
49
49
/**
@@ -62,7 +62,8 @@ type ECSClusterProps = {
62
62
subnetSelection ?: SubnetSelection ;
63
63
taskRoleName ?: string ;
64
64
executionRoleName ?: string ;
65
- } & BaseProps ;
65
+ config : PartialConfig
66
+ } ;
66
67
67
68
/**
68
69
* Create an ECS model.
@@ -90,7 +91,7 @@ export class ECSCluster extends Construct {
90
91
const cluster = new Cluster ( this , createCdkId ( [ ecsConfig . identifier , 'Cl' ] ) , {
91
92
clusterName : createCdkId ( [ config . deploymentName , ecsConfig . identifier ] , 32 , 2 ) ,
92
93
vpc : vpc ,
93
- containerInsightsV2 : ! config . region . includes ( 'iso' ) ? ContainerInsights . ENABLED : ContainerInsights . DISABLED ,
94
+ containerInsightsV2 : ! config . region ? .includes ( 'iso' ) ? ContainerInsights . ENABLED : ContainerInsights . DISABLED ,
94
95
} ) ;
95
96
96
97
// Create auto scaling group
@@ -127,7 +128,7 @@ export class ECSCluster extends Construct {
127
128
// If NVMe drive available, mount and use it
128
129
if ( Ec2Metadata . get ( ecsConfig . instanceType ) . nvmePath ) {
129
130
// EC2 user data to mount ephemeral NVMe drive
130
- const MOUNT_PATH = config . nvmeHostMountPath ;
131
+ const MOUNT_PATH = config . nvmeHostMountPath ?? '/nvme' ;
131
132
const NVME_PATH = Ec2Metadata . get ( ecsConfig . instanceType ) . nvmePath ;
132
133
/* eslint-disable no-useless-escape */
133
134
const rawUserData = `#!/bin/bash
@@ -155,11 +156,11 @@ export class ECSCluster extends Construct {
155
156
156
157
// Create mount point for container
157
158
const sourceVolume = 'nvme' ;
158
- const host : Host = { sourcePath : config . nvmeHostMountPath } ;
159
+ const host : Host = { sourcePath : config . nvmeHostMountPath ?? '/nvme' } ;
159
160
const nvmeVolume : Volume = { name : sourceVolume , host : host } ;
160
161
const nvmeMountPoint : MountPoint = {
161
162
sourceVolume : sourceVolume ,
162
- containerPath : config . nvmeContainerMountPath ,
163
+ containerPath : config . nvmeContainerMountPath ?? '/nvme' ,
163
164
readOnly : false ,
164
165
} ;
165
166
volumes . push ( nvmeVolume ) ;
@@ -171,7 +172,7 @@ export class ECSCluster extends Construct {
171
172
autoScalingGroup . role . addManagedPolicy ( ManagedPolicy . fromAwsManagedPolicyName ( 'AmazonSSMFullAccess' ) ) ;
172
173
}
173
174
174
- if ( config . region . includes ( 'iso' ) ) {
175
+ if ( config . region ? .includes ( 'iso' ) ) {
175
176
const pkiSourceVolume = 'pki' ;
176
177
const pkiHost : Host = { sourcePath : '/etc/pki' } ;
177
178
const pkiVolume : Volume = { name : pkiSourceVolume , host : pkiHost } ;
@@ -184,13 +185,13 @@ export class ECSCluster extends Construct {
184
185
mountPoints . push ( pkiMountPoint ) ;
185
186
// Requires mount point /etc/pki from host
186
187
environment . SSL_CERT_DIR = '/etc/pki/tls/certs' ;
187
- environment . SSL_CERT_FILE = config . certificateAuthorityBundle ;
188
+ environment . SSL_CERT_FILE = config . certificateAuthorityBundle ?? '' ;
188
189
}
189
190
190
191
const roleId = ecsConfig . identifier ;
191
192
const taskRole = taskRoleName ?
192
193
Role . fromRoleName ( this , createCdkId ( [ config . deploymentName , roleId ] ) , taskRoleName ) :
193
- this . createTaskRole ( config . deploymentName , config . deploymentPrefix , roleId ) ;
194
+ this . createTaskRole ( config . deploymentName ?? '' , config . deploymentPrefix , roleId ) ;
194
195
195
196
// Create ECS task definition
196
197
const taskDefinition = new Ec2TaskDefinition ( this , createCdkId ( [ roleId , 'Ec2TaskDefinition' ] ) , {
@@ -263,7 +264,7 @@ export class ECSCluster extends Construct {
263
264
daemon : true ,
264
265
serviceName : createCdkId ( [ config . deploymentName , ecsConfig . identifier ] , 32 , 2 ) ,
265
266
taskDefinition : taskDefinition ,
266
- circuitBreaker : ! config . region . includes ( 'iso' ) ? { rollback : true } : undefined ,
267
+ circuitBreaker : ! config . region ? .includes ( 'iso' ) ? { rollback : true } : undefined ,
267
268
} ;
268
269
269
270
const service = new Ec2Service ( this , createCdkId ( [ ecsConfig . identifier , 'Ec2Svc' ] ) , serviceProps ) ;
0 commit comments