Reputation: 151
I am trying to deploy the lambda function along with the serverless.yml
file to AWS, but it throw below error
The following is the function defined in the YAML file
functions:
s3-thumbnail-generator:
handler:handler.s3_thumbnail_generator
events:
- s3:
bucket: ${self:custom.bucket}
event: s3.ObjectCreated:*
rules:
- suffix: .png
plugins:
- serverless-python-requirements
Error I am getting:
can not read a block mapping entry; a multiline key may not be an implicit key in serverless.yml" at line 45, column 10:
I would need to understand how to fix this issue in YAML file in order to deploy to the function to AWS?
Upvotes: 12
Views: 49234
Reputation: 171
If it is your original file there is a syntax error in your YAML file. I added a note under the line of possible error:
functions:
s3-thumbnail-generator:
handler:handler.s3_thumbnail_generator
events:
- s3:
bucket: ${self:custom.bucket}
event: s3.ObjectCreated:*
rules:
- suffix: .png
^^^ this line should be indented one level
plugins:
- serverless-python-requirements
Upvotes: 0
Reputation: 76832
The problem is that there is no value indicator (:
) at the end of the line:
handler:handler.s3_thumbnail_generator
so the parser continues to try and gather a multi-line plain scalar by adding events
followed by a value indicator. But a multi-line plain scalar cannot be a key in YAML.
It is unclear what your actual error is. It might be that you need to add the value indicator and have a colon emmbedded in your key:
functions:
s3-thumbnail-generator:
handler:handler.s3_thumbnail_generator:
events:
- s3:
bucket: ${self:custom.bucket}
event: s3.ObjectCreated:*
rules:
- suffix: .png
plugins:
- serverless-python-requirements
Or it could be that that colon should have been a value indicator (which usually needs a following space) and you were sloppy with indentation:
functions:
s3-thumbnail-generator:
handler: handler.s3_thumbnail_generator
events:
- s3:
bucket: ${self:custom.bucket}
event: s3.ObjectCreated:*
rules:
- suffix: .png
plugins:
- serverless-python-requirements
Upvotes: 7