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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b14593831320b9c4a774e8e00e2189d1f2640a42f2a3cb6817aaaaeeb79c2bd5
|
|
| MD5 |
33bb3068ea17d85e300f3a87fc68de89
|
|
| BLAKE2b-256 |
2a978c11b0fa907ae095c4e72d53f3d3cfa8243623e0f18a59e6cfa802f36b62
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcc8cda4c957be9ea50f6c1b5e355a4ef423fa850438d64033d55e2616b2b83c
|
|
| MD5 |
4dc722d40b11dcc5d7a49c33285ae3ca
|
|
| BLAKE2b-256 |
af1f7acc337799d1e5201a42f8c1a8f845a119e20051087c5624e55b3ca9212d
|