Question:
Given the following CloudFormation template snippet:
1 2 3 4 5 6 7 8 9 10 11 |
AWSTemplateFormatVersion: 2010-09-09 Resources: PrototypeCreateOrderFDM4: Type: "AWS::Lambda::Function" Properties: CodeUri: "../Lambda/" Handler: "PrototypeCreateOrder.handler" Timeout: 15 Runtime: "nodejs10.x" Role: arn:aws:iam::123456789012:role/deezNutz-Role-1ABC8DDEFGHI |
I’m getting a warning saying that the CodeURI isn’t a valid property:
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
.