On AWS, run an AWS CLI command daily

好久不见. 提交于 2021-01-28 10:51:39

问题


I have an AWS CLI invocation (in this case, to launch a configured EMR cluster to do some steps and then shut down) but I'm not sure how to go about running it daily.

I guess one way to do it is an EC2 micro instance running a cron job, or an ECS task in a micro that launches the command, but that all seems like it might be overkill. It looks like there's also a way to do it in Lambda, but rom what I can tell it'd be kludgy.

This doesn't have to be a good long-term solution, something that's suitable until I can do it right (Data Pipelines) would work just fine.

Suggestions?


回答1:


If it is not a strict requirement to use the AWS CLI, you can use one of the AWS SDK instead to programmatically invoke Lambda.

  • Schedule a CloudWatch Rules using cron
  • When configured, the CloudWatch Rules will trigger a Lambda function
  • Implement a Lambda function that calls EMR using one of the supported SDKs (e.g. the EMR class in the AWS JavaScript SDK)
  • Make sure that you have the IAM configuration in place

Full example is available in the Schedule AWS Lambda Functions Using CloudWatch Events

Kludgy? Yes, configuration is needed, however if you take into account the amount of work required to launch EC2 / ECS (and make sure that it re-launches in the event of failure), I'd say it evens out.




回答2:


Not sure about the whole task that you are doing, but to avoid doing it:

  1. Manually
  2. Avoid another set up for resources in AWS (as you mentioned)

I would create a simple job in a Continuous Integration (CI) server like jenkins,bamboo,circleci ..... (list can go on). I would assume that you might already have a CI server running, why not use it?



来源:https://stackoverflow.com/questions/53735738/on-aws-run-an-aws-cli-command-daily

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!