@sudocdkconstructs/s3-run-fargate-task
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@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.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

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

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    978 kB

    Total Files

    8

    Last publish

    Collaborators

    • sudopla