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
Apiattribute specifies the HTTP method and resource path that is mapped to the Lambda function. The notation isHTTP-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::StageandModule::RestApi::Deploymentreference the API Gateway stage and deployment, respectively.Required: Yes
Type: String
ApiKeyRequired-
The
ApiKeyRequiredattribute indicates whether the method requires clients to submit a valid API key.Required: No
Type: Boolean
AuthorizationType-
The
AuthorizationTypeattribute indicates the authorization type for the method. Valid values areNONEfor open access,AWS_IAMfor using AWS IAM permissions,CUSTOMfor using a custom authorizer, orCOGNITO_USER_POOLSfor using a Cognito user pool.Required: No (Default:
NONE)Type: String
AuthorizationScopes-
The
AuthorizationScopesattribute holds a list of authorization scopes configured on the method. The scopes are used with aCOGNITO_USER_POOLSauthorizer 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
AuthorizerIdattribute holds the identifier of theAuthorizerresource associated with this method.Required: Conditional (Required when
AuthorizerTypeisCUSTOMorCOGNITO_USER_POOLS)Type: String
Invoke-
The
Invokeattribute holds the name of a C# method to invoke in the Lambda function implementation. The Lambda function implementation must derive from theALambdaApiGatewayFunctionclass.Required: No
Type: String
OperationName-
The
OperationNameattribute holds a friendly operation name for the method.NOTE: this attribute inherits the value of
Invokewhen 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