cdk-fargate-run-task


Namecdk-fargate-run-task JSON
Version 2.0.154 PyPI version JSON
download
home_pagehttps://github.com/pahud/cdk-fargate-run-task.git
SummaryDefine and run container tasks on AWS Fargate immediately or with schedule
upload_time2022-10-03 00:14:47
maintainer
docs_urlNone
authorPahud Hsieh<pahudnet@gmail.com>
requires_python~=3.7
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![NPM version](https://badge.fury.io/js/cdk-fargate-run-task.svg)](https://badge.fury.io/js/cdk-fargate-run-task)
[![PyPI version](https://badge.fury.io/py/cdk-fargate-run-task.svg)](https://badge.fury.io/py/cdk-fargate-run-task)
[![build](https://github.com/pahud/cdk-fargate-run-task/actions/workflows/build.yml/badge.svg)](https://github.com/pahud/cdk-fargate-run-task/actions/workflows/build.yml)

# cdk-fargate-run-task

Define and run container tasks on AWS Fargate at once or by schedule.

# sample

```python
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:

```python
new RunTask(stack, 'RunTask', {
  task,
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
  },
```

# ECS Anywhere

[Amazon ECS Anywhere](https://aws.amazon.com/ecs/anywhere/) allows you to run ECS tasks on external instances. To run external task once or on schedule:

```python
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](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere-registration.html) for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pahud/cdk-fargate-run-task.git",
    "name": "cdk-fargate-run-task",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Pahud Hsieh<pahudnet@gmail.com>",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/61/d0/79446d033e4123f2d902ac97fa54f015ebbde19d695624cd5bd490db4843/cdk-fargate-run-task-2.0.154.tar.gz",
    "platform": null,
    "description": "[![NPM version](https://badge.fury.io/js/cdk-fargate-run-task.svg)](https://badge.fury.io/js/cdk-fargate-run-task)\n[![PyPI version](https://badge.fury.io/py/cdk-fargate-run-task.svg)](https://badge.fury.io/py/cdk-fargate-run-task)\n[![build](https://github.com/pahud/cdk-fargate-run-task/actions/workflows/build.yml/badge.svg)](https://github.com/pahud/cdk-fargate-run-task/actions/workflows/build.yml)\n\n# cdk-fargate-run-task\n\nDefine and run container tasks on AWS Fargate at once or by schedule.\n\n# sample\n\n```python\nconst app = new cdk.App();\n\nconst env = {\n  account: process.env.CDK_DEFAULT_ACCOUNT,\n  region: process.env.CDK_DEFAULT_REGION,\n};\n\nconst stack = new cdk.Stack(app, 'run-task-demo-stack', { env });\n\n// define your task\nconst task = new ecs.FargateTaskDefinition(stack, 'Task', { cpu: 256, memoryLimitMiB: 512 });\n\n// add contianer into the task\ntask.addContainer('Ping', {\n  image: ecs.ContainerImage.fromRegistry('busybox'),\n  command: [\n    'sh', '-c',\n    'ping -c 3 google.com',\n  ],\n  logging: new ecs.AwsLogDriver({\n    streamPrefix: 'Ping',\n    logGroup: new LogGroup(stack, 'LogGroup', {\n      logGroupName: `${stack.stackName}LogGroup`,\n      retention: RetentionDays.ONE_DAY,\n    }),\n  }),\n});\n\n// deploy and run this task once\nconst runTaskAtOnce = new RunTask(stack, 'RunDemoTaskOnce', { task });\n\n// or run it with schedule(every hour 0min)\nnew RunTask(stack, 'RunDemoTaskEveryHour', {\n  task,\n  cluster: runTaskAtOnce.cluster,\n  runOnce: false,\n  schedule: Schedule.cron({ minute: '0' }),\n});\n```\n\n## Public Subnets only VPC\n\nTo run task in public subnets only VPC:\n\n```python\nnew RunTask(stack, 'RunTask', {\n  task,\n  vpcSubnets: {\n    subnetType: ec2.SubnetType.PUBLIC,\n  },\n```\n\n# ECS Anywhere\n\n[Amazon ECS Anywhere](https://aws.amazon.com/ecs/anywhere/) allows you to run ECS tasks on external instances. To run external task once or on schedule:\n\n```python\nconst externalTask = new ecs.TaskDefinition(stack, 'ExternalTask', {\n  cpu: '256',\n  memoryMiB: '512',\n  compatibility: ecs.Compatibility.EXTERNAL,\n});\n\nexternalTask.addContainer('ExternalPing', {\n  image: ecs.ContainerImage.fromRegistry('busybox'),\n  command: [\n    'sh', '-c',\n    'ping -c 3 google.com',\n  ],\n  logging: new ecs.AwsLogDriver({\n    streamPrefix: 'Ping',\n    logGroup: new LogGroup(stack, 'ExternalLogGroup', {\n      retention: RetentionDays.ONE_DAY,\n      removalPolicy: cdk.RemovalPolicy.DESTROY,\n    }),\n  }),\n});\n\n// run it once on external instance\nnew RunTask(stack, 'RunDemoTaskFromExternal', {\n  task: externalTask,\n  cluster: existingCluster,\n  launchType: LaunchType.EXTERNAL,\n});\n\n// run it by schedule  on external instance\nnew RunTask(stack, 'RunDemoTaskFromExternalSchedule', {\n  task: externalTask,\n  cluster: existingCluster,\n  launchType: LaunchType.EXTERNAL,\n  runAtOnce: false,\n  schedule: Schedule.cron({ minute: '0' }),\n});\n```\n\nPlease 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](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-anywhere-registration.html) for more details.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Define and run container tasks on AWS Fargate immediately or with schedule",
    "version": "2.0.154",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "035cc46f9452c359fa93b06948a5bd3e",
                "sha256": "56d4a9d983852a1bada9738dc53fb03b5311f9e3d632fc2f3e4eb76ec7b2623a"
            },
            "downloads": -1,
            "filename": "cdk_fargate_run_task-2.0.154-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "035cc46f9452c359fa93b06948a5bd3e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.7",
            "size": 40892,
            "upload_time": "2022-10-03T00:14:45",
            "upload_time_iso_8601": "2022-10-03T00:14:45.304094Z",
            "url": "https://files.pythonhosted.org/packages/d6/82/e20d83f17056b2fbae7ee7cf2b75f0a16bccd38f111ed0ef4946972a473c/cdk_fargate_run_task-2.0.154-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "6a8f9909331aee522502ebcf734f3791",
                "sha256": "777089d1faf8a11e857683e741f68898ec42014fac6c0079d8e1e26b3235135e"
            },
            "downloads": -1,
            "filename": "cdk-fargate-run-task-2.0.154.tar.gz",
            "has_sig": false,
            "md5_digest": "6a8f9909331aee522502ebcf734f3791",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.7",
            "size": 42430,
            "upload_time": "2022-10-03T00:14:47",
            "upload_time_iso_8601": "2022-10-03T00:14:47.854374Z",
            "url": "https://files.pythonhosted.org/packages/61/d0/79446d033e4123f2d902ac97fa54f015ebbde19d695624cd5bd490db4843/cdk-fargate-run-task-2.0.154.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-10-03 00:14:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pahud",
    "github_project": "cdk-fargate-run-task.git",
    "lcname": "cdk-fargate-run-task"
}
        
Elapsed time: 0.45146s