|
| 1 | +import cdk = require('@aws-cdk/cdk'); |
1 | 2 | import { CfnTaskDefinition } from './ecs.generated';
|
2 | 3 |
|
3 | 4 | /**
|
4 |
| - * Linux parameter setup in a container |
| 5 | + * Properties for defining Linux Parameters |
5 | 6 | */
|
6 |
| -export class LinuxParameters { |
| 7 | +export interface LinuxParametersProps { |
7 | 8 | /**
|
8 | 9 | * Whether the init process is enabled
|
9 | 10 | */
|
10 |
| - public initProcessEnabled?: boolean; |
| 11 | + readonly initProcessEnabled?: boolean; |
11 | 12 |
|
12 | 13 | /**
|
13 | 14 | * The shared memory size
|
14 | 15 | */
|
15 |
| - public sharedMemorySize?: number; |
| 16 | + readonly sharedMemorySize?: number; |
| 17 | +} |
| 18 | + |
| 19 | +/** |
| 20 | + * Linux Parameters for an ECS container |
| 21 | + */ |
| 22 | +export class LinuxParameters extends cdk.Construct { |
| 23 | + /** |
| 24 | + * Whether the init process is enabled |
| 25 | + */ |
| 26 | + private readonly initProcessEnabled?: boolean; |
| 27 | + |
| 28 | + /** |
| 29 | + * The shared memory size. Not valid for Fargate launch type |
| 30 | + */ |
| 31 | + private readonly sharedMemorySize?: number; |
16 | 32 |
|
17 | 33 | /**
|
18 | 34 | * Capabilities to be added
|
19 | 35 | */
|
20 |
| - private readonly capAdd: Capability[] = []; |
| 36 | + private readonly capAdd = new Array<Capability>(); |
21 | 37 |
|
22 | 38 | /**
|
23 | 39 | * Capabilities to be dropped
|
24 | 40 | */
|
25 |
| - private readonly capDrop: Capability[] = []; |
| 41 | + private readonly capDrop = new Array<Capability>(); |
26 | 42 |
|
27 | 43 | /**
|
28 | 44 | * Device mounts
|
29 | 45 | */
|
30 |
| - private readonly devices: Device[] = []; |
| 46 | + private readonly devices = new Array<Device>(); |
31 | 47 |
|
32 | 48 | /**
|
33 |
| - * TMPFS mounts |
| 49 | + * TmpFs mounts |
34 | 50 | */
|
35 |
| - private readonly tmpfs: Tmpfs[] = []; |
| 51 | + private readonly tmpfs = new Array<Tmpfs>(); |
| 52 | + |
| 53 | + constructor(scope: cdk.Construct, id: string, props: LinuxParametersProps = {}) { |
| 54 | + super(scope, id); |
| 55 | + |
| 56 | + this.sharedMemorySize = props.sharedMemorySize; |
| 57 | + this.initProcessEnabled = props.initProcessEnabled; |
| 58 | + } |
36 | 59 |
|
37 | 60 | /**
|
38 | 61 | * Add one or more capabilities
|
@@ -61,6 +84,8 @@ export class LinuxParameters {
|
61 | 84 |
|
62 | 85 | /**
|
63 | 86 | * Add one or more tmpfs mounts
|
| 87 | + * |
| 88 | + * Only works with EC2 launch type. |
64 | 89 | */
|
65 | 90 | public addTmpfs(...tmpfs: Tmpfs[]) {
|
66 | 91 | this.tmpfs.push(...tmpfs);
|
|
0 commit comments