Skip to content

Commit e37d16a

Browse files
authored
feat(ec2): added ulimits property to ContainerDefinitionOptions (#24963)
This adds the `ulimits` property to `ContainerDefinitionOptions`, allowing to specify the parameter in the `addContainer` method: ``` const task = ecs.TaskDefinition(...); task.addContainer('id', { ..., ulimits: [{ hardLimit: 128, name: ecs.UlimitName.RSS, softLimit: 128, }], }); ``` Closes #24918. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7ad619d commit e37d16a

14 files changed

+614
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/ec2/integ.task-definition-container-ulimits.js

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "31.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42.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": "31.0.0",
3+
"files": {
4+
"dbbf1e15a2eba9075c0ad89b778826120642d576ca0a58b2830f6b114b984ce5": {
5+
"source": {
6+
"path": "aws-ecs-task-definition-container-ulimits.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "dbbf1e15a2eba9075c0ad89b778826120642d576ca0a58b2830f6b114b984ce5.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,87 @@
1+
{
2+
"Resources": {
3+
"TaskDefTaskRole1EDB4A67": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "ecs-tasks.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
}
18+
}
19+
},
20+
"TaskDef54694570": {
21+
"Type": "AWS::ECS::TaskDefinition",
22+
"Properties": {
23+
"ContainerDefinitions": [
24+
{
25+
"Essential": true,
26+
"Image": "public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest",
27+
"Memory": 512,
28+
"MemoryReservation": 32,
29+
"Name": "Container",
30+
"Ulimits": [
31+
{
32+
"HardLimit": 128,
33+
"Name": "rss",
34+
"SoftLimit": 128
35+
}
36+
]
37+
}
38+
],
39+
"Family": "awsecstaskdefinitioncontainerulimitsTaskDef0C4534B6",
40+
"NetworkMode": "bridge",
41+
"RequiresCompatibilities": [
42+
"EC2"
43+
],
44+
"TaskRoleArn": {
45+
"Fn::GetAtt": [
46+
"TaskDefTaskRole1EDB4A67",
47+
"Arn"
48+
]
49+
}
50+
}
51+
}
52+
},
53+
"Parameters": {
54+
"BootstrapVersion": {
55+
"Type": "AWS::SSM::Parameter::Value<String>",
56+
"Default": "/cdk-bootstrap/hnb659fds/version",
57+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
58+
}
59+
},
60+
"Rules": {
61+
"CheckBootstrapVersion": {
62+
"Assertions": [
63+
{
64+
"Assert": {
65+
"Fn::Not": [
66+
{
67+
"Fn::Contains": [
68+
[
69+
"1",
70+
"2",
71+
"3",
72+
"4",
73+
"5"
74+
],
75+
{
76+
"Ref": "BootstrapVersion"
77+
}
78+
]
79+
}
80+
]
81+
},
82+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
83+
}
84+
]
85+
}
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"31.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "31.0.0",
3+
"testCases": {
4+
"TaskDefinitionContainerUlimits/DefaultTest": {
5+
"stacks": [
6+
"aws-ecs-task-definition-container-ulimits"
7+
],
8+
"assertionStack": "TaskDefinitionContainerUlimits/DefaultTest/DeployAssert",
9+
"assertionStackName": "TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"version": "31.0.0",
3+
"artifacts": {
4+
"aws-ecs-task-definition-container-ulimits.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "aws-ecs-task-definition-container-ulimits.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"aws-ecs-task-definition-container-ulimits": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://unknown-account/unknown-region",
15+
"properties": {
16+
"templateFile": "aws-ecs-task-definition-container-ulimits.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/dbbf1e15a2eba9075c0ad89b778826120642d576ca0a58b2830f6b114b984ce5.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"aws-ecs-task-definition-container-ulimits.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"aws-ecs-task-definition-container-ulimits.assets"
34+
],
35+
"metadata": {
36+
"/aws-ecs-task-definition-container-ulimits/TaskDef/TaskRole/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "TaskDefTaskRole1EDB4A67"
40+
}
41+
],
42+
"/aws-ecs-task-definition-container-ulimits/TaskDef/Resource": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "TaskDef54694570"
46+
}
47+
],
48+
"/aws-ecs-task-definition-container-ulimits/BootstrapVersion": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "BootstrapVersion"
52+
}
53+
],
54+
"/aws-ecs-task-definition-container-ulimits/CheckBootstrapVersion": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "CheckBootstrapVersion"
58+
}
59+
]
60+
},
61+
"displayName": "aws-ecs-task-definition-container-ulimits"
62+
},
63+
"TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42.assets": {
64+
"type": "cdk:asset-manifest",
65+
"properties": {
66+
"file": "TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42.assets.json",
67+
"requiresBootstrapStackVersion": 6,
68+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
69+
}
70+
},
71+
"TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42": {
72+
"type": "aws:cloudformation:stack",
73+
"environment": "aws://unknown-account/unknown-region",
74+
"properties": {
75+
"templateFile": "TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42.template.json",
76+
"validateOnSynth": false,
77+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
78+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
79+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
80+
"requiresBootstrapStackVersion": 6,
81+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
82+
"additionalDependencies": [
83+
"TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42.assets"
84+
],
85+
"lookupRole": {
86+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
87+
"requiresBootstrapStackVersion": 8,
88+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
89+
}
90+
},
91+
"dependencies": [
92+
"TaskDefinitionContainerUlimitsDefaultTestDeployAssert56AB1D42.assets"
93+
],
94+
"metadata": {
95+
"/TaskDefinitionContainerUlimits/DefaultTest/DeployAssert/BootstrapVersion": [
96+
{
97+
"type": "aws:cdk:logicalId",
98+
"data": "BootstrapVersion"
99+
}
100+
],
101+
"/TaskDefinitionContainerUlimits/DefaultTest/DeployAssert/CheckBootstrapVersion": [
102+
{
103+
"type": "aws:cdk:logicalId",
104+
"data": "CheckBootstrapVersion"
105+
}
106+
]
107+
},
108+
"displayName": "TaskDefinitionContainerUlimits/DefaultTest/DeployAssert"
109+
},
110+
"Tree": {
111+
"type": "cdk:tree",
112+
"properties": {
113+
"file": "tree.json"
114+
}
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)