-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ecs): add
maxSwap
and swappiness
properties to LinuxParamete…
…rs (#18703) Add support to `MaxSwap ` and `Swappiness` attributes in the `LinuxParameters` construct. Closes #18460 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
17c94eb
commit 08eb1d6
Showing
13 changed files
with
3,253 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/@aws-cdk/aws-ecs/test/ec2/integ.swap-parameters.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as ec2 from '@aws-cdk/aws-ec2'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import * as integ from '@aws-cdk/integ-tests'; | ||
import * as ecs from '../../lib'; | ||
import { LinuxParameters } from '../../lib'; | ||
|
||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'aws-ecs-integ'); | ||
|
||
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 }); | ||
|
||
// ECS cluster to host EC2 task | ||
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc }); | ||
cluster.addCapacity('DefaultAutoScalingGroup', { | ||
instanceType: new ec2.InstanceType('t2.micro'), | ||
}); | ||
|
||
// define task to run the container | ||
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDefinition', { | ||
networkMode: ecs.NetworkMode.AWS_VPC, | ||
}); | ||
|
||
// define linux parameters to enable swap | ||
const linuxParameters = new LinuxParameters(stack, 'LinuxParameters', { | ||
maxSwap: cdk.Size.gibibytes(5), | ||
swappiness: 90, | ||
}); | ||
|
||
// define container with linux parameters | ||
new ecs.ContainerDefinition(stack, 'Container', { | ||
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'), | ||
linuxParameters, | ||
memoryLimitMiB: 256, | ||
taskDefinition, | ||
}); | ||
|
||
// define a service to run the task definition | ||
new ecs.Ec2Service(stack, 'Service', { | ||
cluster, | ||
taskDefinition, | ||
}); | ||
|
||
new integ.IntegTest(app, 'SwapParametersTest', { | ||
testCases: [stack], | ||
}); | ||
|
||
app.synth(); |
19 changes: 19 additions & 0 deletions
19
...p-parameters.integ.snapshot/SwapParametersTestDefaultTestDeployAssert4CDF4940.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "SwapParametersTestDefaultTestDeployAssert4CDF4940.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
36 changes: 36 additions & 0 deletions
36
...parameters.integ.snapshot/SwapParametersTestDefaultTestDeployAssert4CDF4940.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/@aws-cdk/aws-ecs/test/ec2/swap-parameters.integ.snapshot/aws-ecs-integ.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"cb4c2fe92a33d5f7055fc524d88ede92f68a9c5c5265b0b9a91cb6a20f57a574": { | ||
"source": { | ||
"path": "aws-ecs-integ.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "cb4c2fe92a33d5f7055fc524d88ede92f68a9c5c5265b0b9a91cb6a20f57a574.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
Oops, something went wrong.