I wanted to parameterize the AWS EventBridge cron expression in my Azure DevOps pipeline using a Library Variable Group. However, the deployments kept failing whenever we used that particular variable.
After checking the logs, I found that the cron expression value wasn’t being passed correctly to the deployment stage. It turned out that the issue was caused by special characters and spaces in the expression (such as parentheses, asterisks *, and question marks ?) that were being misinterpreted during YAML parsing.
Solution
To fix this, I changed the variable value in Azure DevOps from
cron(0 8 * * ? *)
to cron(0-8-*-*-?-*)
Then, in my CDKTF (TypeScript) code, I wrote a small helper function to convert the hyphens (-) back to spaces before using it in the AWS EventBridge configuration.
function configureCronString(cron: string): string {
return cron.replace(/-/g, " "); // replaces all '-' with space
}
Later, I had to update the cron expression to a new value: cron(0 13 ? * 2-6 *)
This time, I realized that using - (hyphen) as a delimiter was not safe because it’s a valid character inside cron expressions (for specifying ranges like 2-6).
So, after a bit of testing, I found a better delimiter that doesn’t conflict with cron syntax — the pipe ('|')
symbol.
I modified the variable value in the library to: cron(0|13|?|*|2-6|*)
And updated the helper method accordingly:
function configureCronString(cron: string): string {
return cron.replace(/\|/g, " ");
}
This approach resolved the issue completely and allowed me to deploy the AWS EventBridge rule successfully using CDKTF with dynamic cron expressions from Azure DevOps.
— Lokesh Vangari
Top comments (0)