Skip to content

Commit 6925293

Browse files
authored
feat(aws-ecs-patterns): entryPoint and command support within ApplicationLoadBalancedFargateService and ApplicationLoadBalancedEc2Service (#22609)
Allow `entryPoint` and `command` to be configured via `taskImageOptions` prop in `ApplicationLoadBalancedFargateService` and `ApplicationLoadBalancedEc2Service` example: ```ts const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', { cluster, memoryLimitMiB: 1024, cpu: 512, taskImageOptions: { image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"), command: ["command"], entryPoint: ["entry", "point"], }, }); ``` Closes #17092 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7979d1c commit 6925293

24 files changed

+5636
-1
lines changed

packages/@aws-cdk/aws-ecs-patterns/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const loadBalancedEcsService = new ecsPatterns.ApplicationLoadBalancedEc2Service
3434
TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value",
3535
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value",
3636
},
37+
command: ['command'],
38+
entryPoint: ['entry', 'point'],
3739
},
3840
desiredCount: 2,
3941
});
@@ -49,6 +51,8 @@ const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargat
4951
cpu: 512,
5052
taskImageOptions: {
5153
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
54+
command: ['command'],
55+
entryPoint: ['entry', 'point'],
5256
},
5357
});
5458

packages/@aws-cdk/aws-ecs-patterns/lib/base/application-load-balanced-service-base.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,32 @@ export interface ApplicationLoadBalancedTaskImageOptions {
365365
* @default - No labels.
366366
*/
367367
readonly dockerLabels?: { [key: string]: string };
368+
369+
/**
370+
* The entry point that's passed to the container.
371+
*
372+
* This parameter maps to `Entrypoint` in the [Create a container](https://docs.docker.com/engine/api/v1.38/#operation/ContainerCreate) section
373+
* of the [Docker Remote API](https://docs.docker.com/engine/api/v1.38/) and the `--entrypoint` option to
374+
* [docker run](https://docs.docker.com/engine/reference/commandline/run/).
375+
*
376+
* For more information about the Docker `ENTRYPOINT` parameter, see https://docs.docker.com/engine/reference/builder/#entrypoint.
377+
*
378+
* @default none
379+
*/
380+
readonly entryPoint?: string[];
381+
382+
/**
383+
* The command that's passed to the container. If there are multiple arguments, make sure that each argument is a separated string in the array.
384+
*
385+
* This parameter maps to `Cmd` in the [Create a container](https://docs.docker.com/engine/api/v1.38/#operation/ContainerCreate) section
386+
* of the [Docker Remote API](https://docs.docker.com/engine/api/v1.38/) and the `COMMAND` parameter to
387+
* [docker run](https://docs.docker.com/engine/reference/commandline/run/).
388+
*
389+
* For more information about the Docker `CMD` parameter, see https://docs.docker.com/engine/reference/builder/#cmd.
390+
*
391+
* @default none
392+
*/
393+
readonly command?: string[];
368394
}
369395

370396
/**

packages/@aws-cdk/aws-ecs-patterns/lib/ecs/application-load-balanced-ecs-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ export class ApplicationLoadBalancedEc2Service extends ApplicationLoadBalancedSe
128128
secrets: taskImageOptions.secrets,
129129
logging: logDriver,
130130
dockerLabels: taskImageOptions.dockerLabels,
131+
command: taskImageOptions.command,
132+
entryPoint: taskImageOptions.entryPoint,
131133
});
132134
container.addPortMappings({
133135
containerPort: taskImageOptions.containerPort || 80,

packages/@aws-cdk/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc
8686
environment: taskImageOptions.environment,
8787
secrets: taskImageOptions.secrets,
8888
dockerLabels: taskImageOptions.dockerLabels,
89+
command: taskImageOptions.command,
90+
entryPoint: taskImageOptions.entryPoint,
8991
});
9092
container.addPortMappings({
9193
containerPort: taskImageOptions.containerPort || 80,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "21.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "AlbEc2ServiceWithCommandAndEntryPointDefaultTestDeployAssert91EF33D6.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "21.0.0",
3+
"files": {
4+
"5cad8ed71307fba8ab47a28a3d59925addf1d7a820bca9988c56a087e0476599": {
5+
"source": {
6+
"path": "aws-ecs-integ-alb-ec2-cmd-entrypoint.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "5cad8ed71307fba8ab47a28a3d59925addf1d7a820bca9988c56a087e0476599.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}

0 commit comments

Comments
 (0)