Lambda Resource in CloudFormation Template Reports CodeUri as Invalid

Question:

Given the following CloudFormation template snippet:

I’m getting a warning saying that the CodeURI isn’t a valid property:

enter image description here

I have lots of other Lambda’s structure like this. I’ve never gotten this before. What am I missing?

Answer:

You’re using the AWS::Lambda::Function resource, which doesn’t have a CodeUri property.

You’re probably thinking of the AWS::Serverless::Function from SAM, which supports a CodeUri property.

However, with SAM, you can omit the CodeUri property if your Lambda code is local to your template (and if your handler is under Lambda/index.js, then you can just point the Handler: property to the path directly). Can’t say for sure if this will work with AWS::Lambda::Function, but will definitely with SAM’s AWS::Serverless::Function.

Leave a Reply