Reputation: 11
I am facing issues with passing cron expression as parameter to stack. Seems parameter is getting evaluated to differently than expected. Below are details:
Reading cron expression from json file.
{ "CronSchedule":""cron(0 19 * * * *)"" }
Code snippet of my cloudformation stack.
ScheduledRule:
Type: AWS::Events::Rule
Properties:
Description: ScheduledRule
Name: !Sub '${Environment}-${Platform}-${AppName}-${Prefix}-SCHEDULE-CAPTURE'
ScheduleExpression: !Sub ${CronSchedule}
State: "ENABLED"
AWS command executing:
aws --region us-east-1 cloudformation deploy --template-file ./deployment/aws/cfn/cloudwatch-resources.yml --stack-name QA-DUMMYAPP-CLOUD-WATCH --parameter-overrides Owner=DUMMYAPP AppID=C4E7876D-1BF6-0090-868C-A8E82D4BCBCD BU=DJI AppName=DUMMYAPP Platform=T3 LambdaStackName=QA-DUMMYAPP-LAMBDA ApiGwResourcesStackName=QA-DUMMYAPP-API-GW-RESOURCES CloudWatchStackName=QA-DUMMYAPP-CLOUD-WATCH FeedStateMachineStackName=STACK_NAME Environment=QA CronSchedule="cron(0 19 * * * *)" --no-fail-on-empty-changeset
On AWS Console, cronShedule is displayed as below on the parameter tab.
CronSchedule = *cron(0 19 config deployment pom.xml README.md scripts src config deployment pom.xml README.md scripts src config deployment pom.xml README.md scripts src )
The issue seems to be * is replaced with directory/file names under the directory where cloudformation command is executed.
Any help would be appreciated.
Upvotes: 1
Views: 1992
Reputation: 101
It works for me passing the variable like this:
CronSchedule="'cron(0 19 * * * *)'"
Upvotes: 2
Reputation: 31
You should use the wildcard in the expression. Check the following link Schedule Expressions for Rules
Upvotes: 0