Home > Software design >  Invoke ftp command in fargate container by EventBridge / Crond
Invoke ftp command in fargate container by EventBridge / Crond

Time:04-25

What I want to do is on aws is like this below.

  1. exec ftp command and fetch sql file every hour
  2. push file to RDS.

At first my idea is

  • Making container including crond and ftp then put in fargate.

However, serverless fargate works by crond.....?

So second idea is

  • Making container including ftp, then using EventBridge to run ftp command in container.

Is it possible?

I wonder if I can run the command in container on fargate by EventBridge??

CodePudding user response:

The first step would be to write a bash script that performs the FTP and SQL commands. Then create a container image that includes that bash script, and any dependencies such as mysql or psql. The container image will be configured with the bash script as the entrypoint. This means every time you launch an instance of this container it will perform the FTP and SQL commands, then exit.

Note how at this point all the commands like ftp and the SQL stuff is configured completely inside the image, there is no need for an external service like EventBridge to push the command itself into the container. If there needs to be some configuration passed in, like the FTP server name, or the RDS hostname, those should be passed in as environment variables to the container.

Finally, to run this on ECS Fargate once an hour, you would configure the task definition in ECS, then configure an AWS ECS Scheduled Task, which uses EventBridge, with an hourly cron trigger expression.

  • Related