Adam
Adam

Reputation: 4168

Lambda Resource in CloudFormation Template Reports CodeUri as Invalid

Given the following CloudFormation template snippet:

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:

enter image description here

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

Upvotes: 5

Views: 5678

Answers (1)

Deiv
Deiv

Reputation: 3097

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.

Upvotes: 10

Related Questions