I want an ECS task to be invoked when a user an upload a file to a bucket of choice (the task is to unzip a file). I have managed to sort out pretty much every thing but cannot figure out how to pass the event detail across to ECS to process.
I’ve looked in the docs for specific guidance around this but cannot find anything around this.
I have seen suggestions using InputTransformations that get passed on to containerOverrides in the ECS container. But I cannot find anywhere to do that on the UI (when the target is ECS Task) and when i did that via CDK, nothing happens!
Has anyone managed to get this working? (Suitable alternatives are welcome too)
Here's the list of things you can override on the ECS task when invoking from EventBridge. Further documented in the ECS documentation. To pass in the S3 object event source, you would either need to override the Command
parameter to pass the S3 object key as a parameter to the command, or modify the Environment
to include an environment variable with the S3 object key. I suggest using the Environment
method, and then modifying your code to check that environment variable for the S3 key.
The format of the Object Created event S3 will send to EventBridge is documented here.
The documentation describes how to do this in the AWS Console UI. You would create an Input Transform like the following:
{
containerOverrides = [
{
name = "name-of-container-to-override",
environment = [
{name: 'S3_BUCKET', value: "$.detail.bucket.name"},
{name: 'S3_OBJECT_KEY', value: "$.detail.object.key"},
]
}
]
}