Is there a way to disable the schedule for a scheduled job? I just want to call a fargate function from a lambda so don't need a schedule for it
Hi @sachinahj, the easiest way would be to set the schedule field in the manifest to a date in the past so it will never run. You can do this by using the AWS Events native syntax, which includes an extra "year" field. For example, your manifest might look like:
name: fargate-worker
type: Scheduled Job
image:
build: ./worker/Dockerfile
cpu: 256
memory: 512
on:
schedule: cron(0 0 1 1 ? 2021) # Run at midnight on January 1, 2021
# This will never occur again so the job will never run
Closing this but feel free to reopen if you have any other questions!
I feel this should be an option in the cli rate, fixed schedule, trigger.
I feel this should be an option in the cli
rate, fixed schedule, trigger.
I also feel that this should be an explicit option in the cli that would disable the rule definition in EventBridge / Cloudwatch Events
Hi @kangere ! Would you mind expanding for us, why do you want to disable the rule?
Or are you looking to run a one off task like task run but want the retry/timeout mechanism that state machines provide?
I have a rate expression rather than a cron expression and from the docs it seems that setting the year in the schedule only applies for cron expressions rather than rate expression. So that is why I would suggest disabling the rule, as this would work for both cron and rate expression.
@efekarakus are this assumptions right?
@kangere Is there a reason you can't change your manifest and redeploy the job? Currently, that would be the workaround using only Copilot.
We don't currently have a copilot job enable/disable command but you can do this pretty easily with the AWS CLI outside of Copilot:
RULE_NAME=`aws events list-rules | jq -r '.Rules[] | select(.Name | contains("$APPNAME-$ENVNAME-$JOBNAME-Rule")) | .Name'`
aws events disable-rule --name $RULE_NAME
Does that help?
@bvtujo there isn't any reason I can't change the manifest, it is more of a suggestion since it would reduce the context switching from co-pilot to aws cli.
I believe it would be ideal to manage copilot provisioned infrastructure using the copilot cli rather than having to switch to the aws cli
Understandable! Thanks for bringing this up; I've captured it in #2429. Please give it a thumbs up if it's important to you, as that helps us prioritize!
Most helpful comment
Hi @sachinahj, the easiest way would be to set the
schedulefield in the manifest to a date in the past so it will never run. You can do this by using the AWS Events native syntax, which includes an extra "year" field. For example, your manifest might look like: