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 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::Stage
andModule::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 areNONE
for open access,AWS_IAM
for using AWS IAM permissions,CUSTOM
for using a custom authorizer, orCOGNITO_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 aCOGNITO_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 theAuthorizer
resource associated with this method.Required: Conditional (Required when
AuthorizerType
isCUSTOM
orCOGNITO_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 theALambdaApiGatewayFunction
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