I’ve edited my serverless.yml file to remove a schedule
Then I’ve tried to deploy with sls deploy -v but I’ve got the following message
Serverless Error ---------------------------------------
An error occurred while provisioning your stack: StartInstancesEventsRuleSchedule1- <my_schedule>
exists in stack arn:aws:cloudformation:us-east-1:...
What is the proper way to remove a schedule?
Thanks in advance
What does your serverless.yml
look like?
service: lambda-jobs
plugins:
- serverless-plugin-include-dependencies
provider:
name: aws
runtime: nodejs4.3
# you can add statements to the Lambda function's IAM Role here
iamRoleStatements:
- Effect: Allow
Action:
- ec2:StartInstances
- ec2:StopInstances
- ec2:DescribeInstances
- ec2:DescribeInstanceStatus
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DeleteNetworkInterface
Resource: "*"
Condition:
StringEquals:
ec2:Region: us-east-1
- Effect: Allow
Action:
- kms:Decrypt
Resource: "*"
# you can define service wide environment variables here
environment:
B_ENV: lambda-jobs
B_PRODUCTION: true
functions:
startInstanceAndEtl:
vpc:
securityGroupIds:
- my-sg
subnetIds:
- my-subnet
handler: functions/startInstanceAndEtl.startInstanceAndEtl
timeout: 120
events:
- schedule:
name: 'startInstanceAndEtl_atomic_events'
enabled: true
description: 'startInstanceAndEtl_atomic_events'
rate: cron(30 7 * * ? *)
input:
databaseName: 'atomic_events'
clusterName: ingestor-only-atomic_events
periodicity: default
- schedule:
name: 'startInstanceAndEtl_sales_per_marketing_channel_everyday'
enabled: true
description: 'startInstanceAndEtl_sales_per_marketing_channel_everyday'
rate: cron(50 8 * * ? *)
input:
databaseName: 'sales_per_marketing_channel'
clusterName: ingestor-only-sales_per_marketing
periodicity: default
startInstances:
vpc:
securityGroupIds:
- my-sg
subnetIds:
- my-subnet
handler: functions/startInstance.startInstances
timeout: 120
events:
- schedule:
name: 'start_ingestor_only_fact_sales_saturday'
enabled: true
description: 'start_ingestor_only_fact_sales_saturday'
rate: cron(50 9 ? * SAT *)
input:
clusterName: ingestor_only_fact_sales
periodicity: Saturday
#fact_sale_per_sku_per_store
- schedule:
name: 'start_ingestor_only_fact_sale_per_sku_per_store_sun_to_fri'
enabled: true
description: 'start_ingestor_only_fact_sale_per_sku_per_store_sunday_through_friday'
rate: cron(5 9 ? * SUN-FRI *)
input:
clusterName: ingestor_only_fact_sale_per_sku_per_store
periodicity: default
# you can add CloudFormation resource templates here
#resources:
Resources:
NewResource:
Type: AWS::S3::Bucket
Properties:
BucketName: lambda-jobs
Let’s say if I remove one of the schedules and try to deploy again, I’ll get the same error that the schedule already exists in the stack. This is really weird
Hmmm yeah everything looks ok in serverless.yml
Looks like a potential issue with cloudformation not recognizing one of the schedule events is removed.
Can you file this as an issue on https://github.com/serverless/serverless/issues ?
In the meantime, if you sls remove
the entire stack, and then try and sls deploy
it should tear everything down and start over from scratch
Alright I’ll file this issue =)
For the time being I’ve been using sls remove and sls deploy
The only stuff that I’ve got to do manually is to attach the KMS encryption key to the lambda function role
We found today that it happens when order of “schedule”-s changes
because you removed or added a rule
any idea what is the solution of this problem
if i remove it will work but how we can fix in .yml file ?