question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error for template created with AWS SAM

See original GitHub issue

cfn-lint version: (cfn-lint --version) cfn-lint 0.54.2

Description of issue. Displays an error for a freshly created template using AWS SAM

Please provide as much information as possible:

  • Template linting issues:
    • Please provide a CloudFormation sample that generated the issue.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app

  Sample SAM Template for sam-app
  
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Runtime: nodejs14.x
      Architectures:
        - x86_64
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: get

Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
  HelloWorldApi:
    Description: "API Gateway endpoint URL for Prod stage for Hello World function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  HelloWorldFunction:
    Description: "Hello World Lambda Function ARN"
    Value: !GetAtt HelloWorldFunction.Arn
  HelloWorldFunctionIamRole:
    Description: "Implicit IAM Role created for Hello World function"
    Value: !GetAtt HelloWorldFunctionRole.Arn
  • If present, please add links to the (official) documentation for clarification.
  • Validate if the issue still exists with the latest version of cfn-lint and/or the latest Spec files
  • Feature request:
    • Please provide argumentation about the missing feature. Context is key! I just created a new serverless application using AWS SAM. I ran the following code:
sam init

Selected AWS Quick Start Templates, the Zip package type, Node14.0 as the runtime, and Hello World Example as the application. But the linter gives the follow error:

[cfn-lint] E0001: Error transforming template: Resource with id [HelloWorldFunction] is invalid. property Architectures not defined for resource of type AWS::Serverless::Function

Cfn-lint uses the CloudFormation Resource Specifications as the base to do validation. These files are included as part of the application version. Please update to the latest version of cfn-lint or update the spec files manually (cfn-lint -u)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
PatMyroncommented, Oct 11, 2021

Believe that should be fixed by https://github.com/aws-cloudformation/cfn-lint/pull/2124 or running cfn-lint -u

1reaction
omer-tocommented, Oct 11, 2021

Hi @PatMyron I guess you were right that it was installed with brew.

I ran brew uninstall cfn-lint to remove it, and then ran pip3 install cfn-lint to install it using pip. Here’s the output of pip3 install cfn-lint:

Successfully installed cfn-lint-0.54.2 jsonpatch-1.32 jsonpointer-2.1 junit-xml-1.9 networkx-2.6.3 pyyaml-5.4.1

And the good news is that the error I mentioned in the original post is gone, thought now I’m facing another one 😃 Once again this is the template.yaml (auto generated with sam init - helloworld example)

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app

  Sample SAM Template for sam-app
  
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3

Resources:
  
  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      Handler: hello-world/build/index.handler
      Runtime: nodejs14.x
      Architectures:
        - x86_64
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: post
            RequestParameters:
              - method.request.querystring.name:
                  Required: true
                  Caching: false

The problem displayed by cfn-lint:

[cfn-lint] E3002: Invalid Property Resources/HelloWorldFunction/Properties/Architectures
Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve template validation or template format errors in ... - AWS
I receive an error message when I try to create my AWS CloudFormation stack. Short description. Choose one of the following solutions based...
Read more >
Validating AWS SAM template files
Currently, this command validates that the template provided is valid JSON / YAML. As with most AWS SAM CLI commands, it looks for...
Read more >
Resolve circular dependencies with AWS SAM templates in ...
The template produces an error because it creates the following circular dependency: The Bucket resource depends on the FunctionUploadPermission ...
Read more >
AWS SAM policy templates - AWS Serverless Application Model
The AWS Serverless Application Model (AWS SAM) allows you to choose from a list of policy templates to scope the permissions of your...
Read more >
Resolve the "This template does not include any resources to ...
You receive this error when you use the AWS CloudFormation console to import resources into an existing stack that was created outside of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found