Somehow I cannot figure out how to use the
DependsOn-Property correctly. I want to deploy a lambda function and also add a metric on the logs in one deploy. This fails because the logs are not created yet when serverless would like to create the Metric. I found out that there is a property for my serverless.yml called
DependsOnbut this throws the following error.
The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [myFunction] in the Resources block of the template
I also tried
- Ref: myFunction
but this throws:
The CloudFormation template is invalid: Template format error: Every DependsOn value must be a string.
these are the section from my serverless.yml
Any tips, tricks and pointers into the right direction would be highly appreciated.
The function name (that you need to pass to
DependsOn) is not the name of your function in your
serverless.yml definition - it is the Logical Resource ID of the resource in CloudFormation (see the docs for details), which is generated by Serverless for you when it compiles your CloudFormation template.
Here’s the relevant section of the docs about naming resources. Once you’ve worked out your function’s name, use that in the
DependsOn field and you should be right).
Another way to work it out is to compile your template (using the “
sls package” command) and inspect the file created in the
.serverless directory of your service.
Thanks! Worked like a charm.
Can you guys please share an example
this my yml
rate: rate(10 minutes)
FilterPattern: "“Exception ->”"
i am getting this error
CloudFormation template is invalid: Template format error: Unresolved resource dependencies [/aws/lambda/dc-dev-get, getLambdaFunction] in the Resources block of the template
Ok, resolved. I didn’t realize that the logical ids were case sensitive