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.

sam validate breaks when using Auth block under AWS::Serverless::Api

See original GitHub issue

Description

When having a template.yaml including an Auth property under AWS::Serverless::Api it is invalid with a very confusing error message. If I remove this configuration the sam validate command validates properly.

Steps to reproduce

A template.yaml including:

  ...
  BaseApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod
      Auth:
        DefaultAuthorizer: MyAuthorizer
        Authorizers:
          MyAuthorizer:
            FunctionArn: !GetAtt MyAuthFunction.Arn
            Identity:
              Header: Authorization
              ValidationExpression: Bearer .*
              ReauthorizeEvery: 299 # Seconds

  MyAuthFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: build/
      Handler: myAuthorizer.handler
  ...

Observed result

I skipped the --debug flag as it might include some sensitive information and I didn’t see any valuable output there.

With Auth config:

$ sam validate
Template provided at '/var/opt/template.yaml' was invalid SAM Template.
Error:  

Without Auth config:

$ sam validate
/var/opt/template.yaml is a valid SAM Template

Expected result

The template would be valid even with an Auth section defined.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Linux
  2. sam --version: 0.13.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
piersfcommented, Apr 27, 2020

Was there a solution to this? I got the same error today:

Error: [InvalidResourceException(ManagementApi', "Invalid value for 'Auth' property")] ('ManagementApi', "Invalid value for 'Auth' property")

In my case, the issue appears when i add UsagePlan under the Auth object.

I am using SAM CLI, version 0.41.0 and Python 3.7.4

sam deploy works fine, however

Adding swagger: 2.0 under DefinitionBody as mentioned in https://github.com/awslabs/aws-sam-cli/issues/803#issuecomment-616817020 does not fix anything.

2reactions
jackmcguire1commented, Apr 27, 2019

Any progress on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sam validate breaks when using Auth block under AWS ...
When having a template.yaml including an Auth property under AWS::Serverless::Api it is invalid with a very confusing error message. If I remove ...
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 >
Step-through debugging Lambda functions locally
To run AWS SAM in debug mode, use commands sam local invoke or sam local start-api with the --debug-port or -d option. For...
Read more >
Controlling access to API Gateway APIs - AWS Documentation
AWS SAM supports several mechanisms for controlling access to your API Gateway APIs. The set of supported mechanisms differs between AWS::Serverless::HttpApi ...
Read more >
Announcing nested applications for AWS SAM and the AWS ...
I can use AWS SAM to create Lambda functions, configure API Gateway, and deploy and manage them both. To start building, I can...
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