Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x-amazon-apigateway-request-validators and integration not being applied localy #516

Closed
mac2000 opened this issue Jun 29, 2018 · 1 comment

Comments

@mac2000
Copy link

mac2000 commented Jun 29, 2018

Description:

I have taken inline_swagger template and modified it to use x-amazon-apigateway-request-validators to not even call my lambda if request is incorrect, but seems like lambda is still invoking in proxy mode

Steps to reproduce the issue:

template.yml

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Simple API Endpoint configured using Swagger specified inline and backed by a Lambda function
Resources:
  MyApi:
    Type: AWS::Serverless::Api
    Properties:
        StageName: prod
        DefinitionBody:
            swagger: 2.0
            info:
              title:
                Ref: AWS::StackName
            paths:
              "/get/{id}":
                get:
                  produces:
                  - application/json
                  parameters:
                  - name: "id"
                    in: "path"
                    required: true
                    type: "string"
                  responses: {}
                  x-amazon-apigateway-request-validator: "Validate body"
                  x-amazon-apigateway-integration:
                    uri:
                      Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${MyLambdaFunction.Arn}/invocations
                    requestTemplates:
                      application/json: "{\"id\":\"$input.params('id')\"}"
                    responses:
                      default:
                        statusCode: 200
                    httpMethod: POST
                    type: aws
            x-amazon-apigateway-request-validators:
              Validate body:
                validateRequestParameters: false
                validateRequestBody: true



            
  MyLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs8.10
      CodeUri: src/
      Events:
        GetApi:
          Type: Api
          Properties:
            Path: /get/{id}
            Method: GET
            RestApiId: 
                Ref: MyApi

Outputs:

    ApiURL:
      Description: "API endpoint URL for Prod environment"
      Value: !Sub "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/prod/get"

src/index.js

exports.handler = async event => {
    console.log(event)
    return {
        body: 'hello world' + event.id
    }
}

Invokation:

curl http://localhost:3000/get/2

Observed result:

In sam local stdout I do see log containing integration request object with headers, query string and pas parameters

Expected result:

lambda should be called with event containg id only

Cross posted from: aws/serverless-application-model#455 (comment)

@jfuss
Copy link
Contributor

jfuss commented Jun 29, 2018

Duplicate of #364

Closing

@jfuss jfuss closed this as completed Jun 29, 2018
hawflau pushed a commit to hawflau/aws-sam-cli that referenced this issue Oct 10, 2023
* Provided.al2023 implementation

* Provided.al2023 implementation

* Added provided.al2023 to PREVIEW_RUNTIMES
hawflau added a commit that referenced this issue Oct 10, 2023
* Provided.al2023 runtime (#516)

* Provided.al2023 implementation

* Provided.al2023 implementation

* Added provided.al2023 to PREVIEW_RUNTIMES

* fix test

* fix set

---------

Co-authored-by: Anton Stepanov <110172761+anton-stepanof@users.noreply.github.com>
hawflau added a commit that referenced this issue Oct 11, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 11, 2023
moelasmar pushed a commit to moelasmar/aws-sam-cli that referenced this issue Oct 22, 2023
* Provided.al2023 runtime (aws#516)

* Provided.al2023 implementation

* Provided.al2023 implementation

* Added provided.al2023 to PREVIEW_RUNTIMES

* fix test

* fix set

---------

Co-authored-by: Anton Stepanov <110172761+anton-stepanof@users.noreply.github.com>
moelasmar pushed a commit to moelasmar/aws-sam-cli that referenced this issue Oct 22, 2023
hawflau added a commit that referenced this issue Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants