Skip to main content

Run Fargate task with S3 upload event

Project description

@sudocdkconstructs/s3-run-fargate-task

It's a very common AWS pattern to run a Fargate task when a file is uploaded to a S3 bucket. Usually developers create a Lambda function that is connected to S3 event notifications and starts the Fargate task. This construct uses a little different approach. It enables S3 EventBridge notifications in the bucket and creates a rule that runs the Fargate task. It passes the bucket name and object key to the container as an environment variables. Notice that it does not required a Lambda function.

Install

TypeScript/JavaScript:

npm i @sudocdkconstructs/s3-run-fargate-task

Python:

pip install sudocdkconstructs.s3-run-fargate-task

How to use

const bucket = new cdk.aws_s3.Bucket(this, 'Bucket', {
    bucketName: 's3-fargate-bucket'
})

new S3RunFargateTask(this, 'S3RunFargateTask', {
    bucket,
    ruleName: 'cdk-run-fargate-rule',
    clusterName: 'FargateCluster',
    ruleDescription: 's3 event runs fargate task',
    taskDefinitionArn: 'arn:aws:ecs:us-east-1:002020202:task-definition/FargateTask:9',
    containerName: 'processContainer',
    subnetIds: ['subnet-0001', 'subnet-00002'],
    securityGroups: ['sg-00001']
})

The bucket name will be in the container environment variable BUCKET and the object key in the KEY variable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sudocdkconstructs.s3-run-fargate-task-1.0.1.tar.gz (108.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file sudocdkconstructs.s3-run-fargate-task-1.0.1.tar.gz.

File metadata

  • Download URL: sudocdkconstructs.s3-run-fargate-task-1.0.1.tar.gz
  • Upload date:
  • Size: 108.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for sudocdkconstructs.s3-run-fargate-task-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b14593831320b9c4a774e8e00e2189d1f2640a42f2a3cb6817aaaaeeb79c2bd5
MD5 33bb3068ea17d85e300f3a87fc68de89
BLAKE2b-256 2a978c11b0fa907ae095c4e72d53f3d3cfa8243623e0f18a59e6cfa802f36b62

See more details on using hashes here.

File details

Details for the file sudocdkconstructs.s3_run_fargate_task-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sudocdkconstructs.s3_run_fargate_task-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 107.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for sudocdkconstructs.s3_run_fargate_task-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fcc8cda4c957be9ea50f6c1b5e355a4ef423fa850438d64033d55e2616b2b83c
MD5 4dc722d40b11dcc5d7a49c33285ae3ca
BLAKE2b-256 af1f7acc337799d1e5201a42f8c1a8f845a119e20051087c5624e55b3ca9212d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page