aws-cloudformation / cfn-lint

CloudFormation Linter
MIT No Attribution
2.45k stars 592 forks source link

Support for the docker lambda runtime #1828

Closed RyanJarv closed 2 years ago

RyanJarv commented 3 years ago

cfn-lint 0.43.0

This is a feature request for supporting docker lambda sam templates.

Please provide as much information as possible:

Running on the template.yaml in the base directory outputs the following:

% cfn-lint template.yaml                  
E0001 Error transforming template: Resource with id [HelloWorldFunction] is invalid. 'ImageUri' must be set.
template.yaml:1:1

Running on the packaged template at .aws-sam/build/template.yaml produces the following:

E3002 Invalid Property Resources/HelloWorldFunction/Properties/Code/ImageUri
.aws-sam/build/template.yaml:12:3

E3002 Invalid Property Resources/HelloWorldFunction/Properties/PackageType
.aws-sam/build/template.yaml:12:3

E3003 Property Handler missing at Resources/HelloWorldFunction/Properties
.aws-sam/build/template.yaml:12:3

E3003 Property Runtime missing at Resources/HelloWorldFunction/Properties
.aws-sam/build/template.yaml:12:3
PatMyron commented 3 years ago

could you include your template?

The second half likely involves https://github.com/aws-cloudformation/cfn-python-lint/issues/1219 since no Resource Specfications have been released for weeks

The first half may be fixed by upgrading SAM: pip3 install aws-sam-translator --upgrade

PatMyron commented 3 years ago

fixes for the second half just merged in yesterday, so the second half will be fixed in the next release

kddejong commented 3 years ago

This template is working with the newest version of the sam translator. If you leave that value out you will get the error that you have specified but that error is coming from https://github.com/aws/serverless-application-model if you believe it shouldn't exist we may need to create an issue there.

Transform: AWS::Serverless-2016-10-31
Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Image
      ImageUri: 123456789.dkr.ecr.region.amazonaws.suffix/myimage:latest
      ImageConfig:
        Command:
          - "app.lambda_handler"
        EntryPoint:
          - "entrypoint1"
        WorkingDirectory: "workDir"

v0.44.2 is out and includes the 2nd half fixes that @PatMyron mentioned.

dquam commented 2 years ago

@kddejong - I think this needs to be re-opened. The original issue is still present. It was fixed in sam validate here. From that fix, here is a test that will fail cfn-lint.

The problem is that cfn-lint passes the template as-is to the transalator, but sam will deploy an image to ECR then add an ImageUri before translating.