Show / Hide Table of Contents

API Gateway Source

The LambdaSharp CLI uses the API Gateway Lambda Proxy Integration to invoke Lambda functions from API Gateway. See API Gateway sample for an example of how to use the API Gateway source.

Syntax

Api: String
ApiKeyRequired: Boolean
AuthorizationType: String
AuthorizationScopes:
  - String
AuthorizerId: String
OperationName: String
Invoke: String

Properties

Api

The Api attribute specifies the HTTP method and resource path that is mapped to the Lambda function. The notation is HTTP-METHOD:/resource/{param}. The API Gateway instance, the API Gateway resources, and the API Gateway methods are automatically created for the module when an API Gateway source is used.

NOTE: The API Gateway resource can be referenced by its name Module::RestApi. Similarly, Module::RestApi::Stage and Module::RestApi::Deployment reference the API Gateway stage and deployment, respectively.

Required: Yes

Type: String

ApiKeyRequired

The ApiKeyRequired attribute indicates whether the method requires clients to submit a valid API key.

Required: No

Type: Boolean

AuthorizationType

The AuthorizationType attribute indicates the authorization type for the method. Valid values are NONE for open access, AWS_IAM for using AWS IAM permissions, CUSTOM for using a custom authorizer, or COGNITO_USER_POOLS for using a Cognito user pool.

Required: No (Default: NONE)

Type: String

AuthorizationScopes

The AuthorizationScopes attribute holds a list of authorization scopes configured on the method. The scopes are used with a COGNITO_USER_POOLS authorizer to authorize the method invocation. The authorization works by matching the method scopes against the scopes parsed from the access token in the incoming request. The method invocation is authorized if any method scopes match a claimed scope in the access token. Otherwise, the invocation is not authorized. When the method scope is configured, the client must provide an access token instead of an identity token for authorization purposes.

Required: No

Type: List of String

AuthorizerId

The AuthorizerId attribute holds the identifier of the Authorizer resource associated with this method.

Required: Conditional (Required when AuthorizerType is CUSTOM or COGNITO_USER_POOLS)

Type: String

Invoke

The Invoke attribute holds the name of a C# method to invoke in the Lambda function implementation. The Lambda function implementation must derive from the ALambdaApiGatewayFunction class.

Required: No

Type: String

OperationName

The OperationName attribute holds a friendly operation name for the method.

NOTE: this attribute inherits the value of Invoke when not set.

Required: No

Type: String

Examples

A LambdaFunction can respond to multiple API Gateway endpoints at once.

Sources:

  - Api: GET:/items/{id}

  - Api: POST:/items
    OperationName: AddItem
    ApiKeyRequired: true

  - Api: DELETE:/items/{id}
    ApiKeyRequired: true
    OperationName: RemoveItem
In This Article
Back to top Generated by DocFX