cdk-fargate-run-task 2.0.397
pip install cdk-fargate-run-task
Released:
Define and run container tasks on AWS Fargate immediately or with schedule
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: OSI Approved (Apache-2.0)
- Author: Pahud Hsieh<pahudnet@gmail.com>
- Requires: Python ~=3.7
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
- Typing
Project description
cdk-fargate-run-task
Define and run container tasks on AWS Fargate at once or by schedule.
sample
const app = new cdk.App();
const env = {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
};
const stack = new cdk.Stack(app, 'run-task-demo-stack', { env });
// define your task
const task = new ecs.FargateTaskDefinition(stack, 'Task', { cpu: 256, memoryLimitMiB: 512 });
// add contianer into the task
task.addContainer('Ping', {
image: ecs.ContainerImage.fromRegistry('busybox'),
command: [
'sh', '-c',
'ping -c 3 google.com',
],
logging: new ecs.AwsLogDriver({
streamPrefix: 'Ping',
logGroup: new LogGroup(stack, 'LogGroup', {
logGroupName: `${stack.stackName}LogGroup`,
retention: RetentionDays.ONE_DAY,
}),
}),
});
// deploy and run this task once
const runTaskAtOnce = new RunTask(stack, 'RunDemoTaskOnce', { task });
// or run it with schedule(every hour 0min)
new RunTask(stack, 'RunDemoTaskEveryHour', {
task,
cluster: runTaskAtOnce.cluster,
runOnce: false,
schedule: Schedule.cron({ minute: '0' }),
});
Public Subnets only VPC
To run task in public subnets only VPC:
new RunTask(stack, 'RunTask', {
task,
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
ECS Anywhere
Amazon ECS Anywhere allows you to run ECS tasks on external instances. To run external task once or on schedule:
const externalTask = new ecs.TaskDefinition(stack, 'ExternalTask', {
cpu: '256',
memoryMiB: '512',
compatibility: ecs.Compatibility.EXTERNAL,
});
externalTask.addContainer('ExternalPing', {
image: ecs.ContainerImage.fromRegistry('busybox'),
command: [
'sh', '-c',
'ping -c 3 google.com',
],
logging: new ecs.AwsLogDriver({
streamPrefix: 'Ping',
logGroup: new LogGroup(stack, 'ExternalLogGroup', {
retention: RetentionDays.ONE_DAY,
removalPolicy: cdk.RemovalPolicy.DESTROY,
}),
}),
});
// run it once on external instance
new RunTask(stack, 'RunDemoTaskFromExternal', {
task: externalTask,
cluster: existingCluster,
launchType: LaunchType.EXTERNAL,
});
// run it by schedule on external instance
new RunTask(stack, 'RunDemoTaskFromExternalSchedule', {
task: externalTask,
cluster: existingCluster,
launchType: LaunchType.EXTERNAL,
runAtOnce: false,
schedule: Schedule.cron({ minute: '0' }),
});
Please note when you run task in EXTERNAL
launch type, no fargate tasks will be scheduled. You will be responsible to register the external instances to your ECS cluster. See Registering an external instance to a cluster for more details.
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: OSI Approved (Apache-2.0)
- Author: Pahud Hsieh<pahudnet@gmail.com>
- Requires: Python ~=3.7
Classifiers
- Development Status
- Intended Audience
- License
- Operating System
- Programming Language
- Typing
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cdk-fargate-run-task-2.0.397.tar.gz
.
File metadata
- Download URL: cdk-fargate-run-task-2.0.397.tar.gz
- Upload date:
- Size: 44.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 439e70ea6e001c638c8455fb28fc95af7869083c952a7bbc4667a14afb5e50ce |
|
MD5 | f863deaa73cb1e273cd80c34295115b6 |
|
BLAKE2b-256 | 14d2805101329eb42733c1b33dab01fd1b2d4cd9203ccc22f97fb965e47c7021 |
File details
Details for the file cdk_fargate_run_task-2.0.397-py3-none-any.whl
.
File metadata
- Download URL: cdk_fargate_run_task-2.0.397-py3-none-any.whl
- Upload date:
- Size: 42.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b5b3785e7ad87390fcefb75faf26c885bfcbd8133407fbd310df72fc9db546b |
|
MD5 | 7b46a35e5ebc7e0480888d80a9b53a0b |
|
BLAKE2b-256 | 6db78c2276bc42db5e7164fb153603c4d7cb34c0e88924382c921696fc65a13b |