What I want to do is on aws
is like this below.
- exec ftp command and fetch sql file every hour
- push file to RDS.
At first my idea is
- Making container including
crond
andftp
then put infargate
.
However, serverless fargate works by crond.....?
So second idea is
- Making container including
ftp
, then usingEventBridge
to runftp
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.