amazon-web-servicesamazon-s3boto3aws-fargateamazon-cloudwatch-events

AWS question - How can I get Cloudwatch event data in a Fargate task with Python


I'm new to Cloudwatch events and to Fargate. I want to trigger a Fargate task (Python) to run whenever a file is uploaded to a specific S3 bucket. I can get the task to run whenever I upload a file, and can see the name in the event log; however I can't figure out a simple way to read the event data in Fargate. I've been researching this the past couple of days and haven't found solution other than reading the event log or using a lambda to invoke the task and to put the event data in a message queue.

Is there a simple way to obtain the event data in Fargate with boto3? It's likely that I'm not looking in the right places or asking the right question.

Thanks


Solution

  • One of the easiest options that you can configure is two targets for same s3 image upload event.

    Read Message Event from SQS when Fargate is up (No Lambda in between), also same task definition that will work a normal use case, make sure you exit the process after reading the message from sqs.

    So in this case whenever Fargate Task up, it will read messages from the SQS. enter image description here