2017-08-18 6 views
0

AWSの新機能です。私はそれが非常に平凡な質問かもしれないことを知っています。 AWSラムダプロキシでパラメータを渡して受け入れようとしています。私はbody mappingテンプレートを使用してAWSのラムダでそれを行うことができた、私たちはラムダプロキシにおけるAWSのラムダにマップqueryStringを得ることが可能な任意の方法はありAWSラムダとAWSラムダプロキシの違いは何ですか?

答えて

2

あなたはラムダプロキシを使用している場合は、APIゲートウェイは、全クライアント要求をマッピングします次のようにバックエンドラムダ関数の入力イベントパラメータに渡します。

{ 
    "resource": "Resource path", 
    "path": "Path parameter", 
    "httpMethod": "Incoming request's method name" 
    "headers": {Incoming request headers} 
    "queryStringParameters": {query string parameters } 
    "pathParameters": {path parameters} 
    "stageVariables": {Applicable stage variables} 
    "requestContext": {Request context, including authorizer-returned key-value pairs} 
    "body": "A JSON string of the request payload." 
    "isBase64Encoded": "A boolean flag to indicate if the applicable request payload is Base64-encode"} 

AWSのセットアッププロキシインテグレーションdocumentationを参照してください。

ここには、クエリ文字列などのイベントデータを解析する方法のexampleがあります。

+0

おかげで、私は 'パス' 変数を使用して、私のエンドポイントにアクセスすることができています – WPrathamesh

0

ラムダとAPIゲートウェイを開発して展開するためにサーバーレスフレームワークを使用している人は、オープンAPI仕様、Swaggerを使用してAWSラムダプロキシとしてAPIゲートウェイを設定する方法があります。次の構成例を参照してください。

resources: 
 
    Resources: 
 
    SupportProxy: 
 
     Type: "AWS::ApiGateway::RestApi" 
 
     Properties: 
 
     Name: lambda-proxy 
 
     Description: "The API proxy entry point." 
 
     Body: 
 
      swagger: '2.0' 
 
      info: 
 
      version: '2016-09-12T23:19:28Z' 
 
      title: ProxyResource 
 
      basePath: /myapp 
 
      schemes: 
 
      - https 
 
      # Work-around to prevent API Gateway from trying to re-encode binary files (images, fonts, etc) as unicode text. 
 
      x-amazon-apigateway-binary-media-types: 
 
      - '*/*' 
 
      paths: 
 
      /myapp/service1/{proxy+}: 
 
       x-amazon-apigateway-any-method: 
 
       parameters: 
 
        - name: proxy 
 
        in: path 
 
        required: true 
 
        type: string 
 
       responses: {} 
 
       x-amazon-apigateway-integration: 
 
        responses: 
 
        default: 
 
         statusCode: '200' 
 
        requestParameters: 
 
        integration.request.path.proxy: method.request.path.proxy 
 
        uri: ${service1.url}/{proxy} 
 
        passthroughBehavior: when_no_match 
 
        httpMethod: ANY 
 
        type: http_proxy