Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
330 views
in Technique[技术] by (71.8m points)

amazon ecs - How to force fargate service to be launched only from AWS Lambda

I've created a simple task to print a hello world. I've created a ECR image, docker compose and ecs-params.yml.

I get the cloudwatch log for the print, but the task keeps launching every minute, which I guess it's due to REPLICA service type.

How can I stop this from happening, I want to launch this Fargate task ONLY from a lambda, and when it finishes I don't it to be relaunched.

Thanks in advance

question from:https://stackoverflow.com/questions/65918738/how-to-force-fargate-service-to-be-launched-only-from-aws-lambda

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you want a one-shot / one-off / standalone task to be launched by ECS and have it run until it finishes, you wouldn't use an ECS service definition but merely a task. You can run tasks on their own without packaging as an ECS service.

See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_run_task.html

If you are using the ECS CLI, then there is also ecs-cli compose create. So, you would use that call and not the one also creating an ECS service along with it.

You can then use AWS Lambda and send an ecs:RunTask AWS API call to invoke/start the ECS task.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...