Modifying service token is not allowed

I am getting the error “Modifying service token is not allowed” while trying to redeploy the serverless.yml. I am not sure why it doesn’t allow to update the resource. Any help will be appriciatted.

function defined as below:

studentContentEvent:
handler: studentContent
name: clapi-{self:provider.stagePrifix}-studentContent package: artifact: ./artifacts/studentContent.zip events: - s3: bucket: {self:provider.contentBucket}
events:
- s3:ObjectCreated:*
existing: true

Resoure is created as below:

ContentBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.contentBucket}
VersioningConfiguration:
Status: Enabled
CorsConfiguration:
CorsRules:
- AllowedHeaders:
- “"
AllowedMethods:
- “GET”
- “PUT”
AllowedOrigins:
- "

MaxAge: 3000
ExposedHeaders:
- x-amz-version-id
- Server

For any future visitors, I had the same issue when using sls-deploy through Github CI. I was installing it on the fly before running the deploy. I realised this would install the latest version of serverless every time which might contain bugs as they release regularly to npm.

After I locked it to the older version (2.28.7) that was working fine on my local machine, it fixed this issue.

I was given the same error because some how sls deploy generated function name myfunctionname-undefined-resource-apigw-cw-role on CustomDashresourceDashapigwDashcwDashroleLambdaFunction on the cloudformation template instead of the default stage dev. Specifying stage with command sls deploy --stage dev fixed it

1 Like

This worked for me as well

I’m getting this problem too. --stage dev fixes it, but can anyone explain why it’s happening it and what needs to be done to avoid it?