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.

Linting exception for valid SAM Api resource

See original GitHub issue

cfn-lint version: 0.27.1

Description of issue

RestApiId is not recognised as a valid type for type AWS::Serverless::Function

AWSTemplateFormatVersion: 2010-09-09

Transform: AWS::Serverless-2016-10-31

Description: The cloudformation includes all lambda definitions.

Globals:
  Function:
    Runtime: go1.x
    Timeout: 5
    Handler: main

Parameters:
  AllowedCORSDomain:
    Type: String
  ParentStackName:
    Type: String
  ApiGatewayStageName:
    Type: String
  StripePrivateKey:
    Type: String

Resources:
  HelloWorldFunction:
    Properties:
      CodeUri: ../go/lambda/hello-world/
      Events:
        Api:
          Properties:
            Method: Get
            Path: /
            RestApiId:
              Ref: ApiGateway
          Type: Api
      FunctionName: Hello-world
    Type: AWS::Serverless::Function

  ApiGateway:
    Properties:
      Cors:
        AllowMethods: "'OPTIONS,POST,GET'"
        AllowHeaders: "'Content-Type'"
        AllowOrigin: !Ref AllowedCORSDomain
      DefinitionBody:
        openapi: '3.0'
        bathPath: /
        schemes:
          - https
        paths:
          /hello:
            get:
              responses:
                '200': {}
              x-amazon-apigateway-integration:
                type: 'aws_proxy'
                httpMethod: 'POST'
                uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloWorldFunction.Arn}/invocations
      MethodSettings:
        - DataTraceEnabled: true
          HttpMethod: "*"
          LoggingLevel: INFO
          MetricsEnabled: true
          ResourcePath: /*
      Name: Hello-world-ApiGateway
      OpenApiVersion: '2.0'
      StageName: dev
    Type: AWS::Serverless::Api

The way of setting APIGateway comes from aws document.

Error:

Error transforming template: unhashable type: 'dict_node' [E0001]. 

If comment out RestApiId: !Ref ApiGateway, then works.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JustinLiang90commented, Jan 21, 2020

can you do a pip list and tell me what version of aws-sam-translator you have?

@kddejong aws-sam-translator version is 1.20.1

I haven’t been able to replicate the issue so I’m wondering if you have a different version of that package than I do.

Sorry, I updated the template. so now, you should see the error, and if I comment out

RestApiId:
  Ref: ApiGateway

or FunctionName: Hello-world, then it will work

1reaction
kddejongcommented, Jan 21, 2020

@JustinLiang90 can you do a pip list and tell me what version of aws-sam-translator you have?

E0001 on a SAM translator are the result of us getting an error back from that package. I haven’t been able to replicate the issue so I’m wondering if you have a different version of that package than I do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linting exception for valid SAM Api resource #1325 - GitHub
The way of setting APIGateway comes from aws document. Error: Error transforming template: unhashable type: 'dict_node' [E0001].
Read more >
Validating AWS SAM template files
Validate your templates with sam validate . Currently, this command validates that the template provided is valid JSON / YAML. As with most...
Read more >
What causes my SAM template to generate that many errors
I am able to do GET requests, but CORS is preventing me from doing the PUT and POST requests. What is redundant and...
Read more >
Deploy a serverless API using lambda with SAM CLI and a ...
SAM Cli uses a swagger file to configure the Gateway API, an interface ... COLOR_BGR2RGB) res.append(infer_func(img)) except Exception as e: ...
Read more >
Top 10 Serverless Deployment Errors (and How to Fix Them)
The CloudFormation stack is in an invalid state for preparation ... This error is caused when creating a API Gateway resource with a...
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