amazonka-lambda-1.6.1: Amazon Lambda SDK.

Copyright(c) 2013-2018 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Network.AWS.Lambda.Invoke

Contents

Description

Invokes a specific Lambda function. For an example, see Create the Lambda Function and Test It Manually .

If you are using the versioning feature, you can invoke the specific function version by providing function version or alias name that is pointing to the function version using the Qualifier parameter in the request. If you don't provide the Qualifier parameter, the > LATEST version of the Lambda function is invoked. Invocations occur at least once in response to an event and functions must be idempotent to handle this. For information about the versioning feature, see AWS Lambda Function Versioning and Aliases .

This operation requires permission for the lambda:InvokeFunction action.

Synopsis

Creating a Request

invoke Source #

Creates a value of Invoke with the minimum fields required to make a request.

Use one of the following lenses to modify other fields as desired:

  • iInvocationType - By default, the Invoke API assumes RequestResponse invocation type. You can optionally request asynchronous execution by specifying Event as the InvocationType . You can also use this parameter to request AWS Lambda to not execute the function but do some verification, such as if the caller is authorized to invoke the function and if the inputs are valid. You request this by specifying DryRun as the InvocationType . This is useful in a cross-account scenario when you want to verify access to a function without running it.
  • iLogType - You can set this optional parameter to Tail in the request only if you specify the InvocationType parameter with value RequestResponse . In this case, AWS Lambda returns the base64-encoded last 4 KB of log data produced by your Lambda function in the x-amz-log-result header.
  • iQualifier - You can use this optional parameter to specify a Lambda function version or alias name. If you specify a function version, the API uses the qualified function ARN to invoke a specific Lambda function. If you specify an alias name, the API uses the alias ARN to invoke the Lambda function version to which the alias points. If you don't provide this parameter, then the API uses unqualified function ARN which results in invocation of the > LATEST version.
  • iClientContext - Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, see PutEvents in the Amazon Mobile Analytics API Reference and User Guide . The ClientContext JSON must be base64-encoded and has a maximum size of 3583 bytes.
  • iFunctionName - The Lambda function name. You can specify a function name (for example, Thumbnail ) or you can specify Amazon Resource Name (ARN) of the function (for example, arn:aws:lambda:us-west-2:account-id:function:ThumbNail ). AWS Lambda also allows you to specify a partial ARN (for example, account-id:Thumbnail ). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 characters in length.
  • iPayload - JSON that you want to provide to your Lambda function as input.

data Invoke Source #

See: invoke smart constructor.

Instances
Eq Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

(==) :: Invoke -> Invoke -> Bool #

(/=) :: Invoke -> Invoke -> Bool #

Data Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Invoke -> c Invoke #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Invoke #

toConstr :: Invoke -> Constr #

dataTypeOf :: Invoke -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Invoke) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Invoke) #

gmapT :: (forall b. Data b => b -> b) -> Invoke -> Invoke #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Invoke -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Invoke -> r #

gmapQ :: (forall d. Data d => d -> u) -> Invoke -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Invoke -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Invoke -> m Invoke #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Invoke -> m Invoke #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Invoke -> m Invoke #

Show Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Generic Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Associated Types

type Rep Invoke :: Type -> Type #

Methods

from :: Invoke -> Rep Invoke x #

to :: Rep Invoke x -> Invoke #

Hashable Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

hashWithSalt :: Int -> Invoke -> Int #

hash :: Invoke -> Int #

AWSRequest Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Associated Types

type Rs Invoke :: Type #

ToBody Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

toBody :: Invoke -> RqBody #

ToHeaders Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

toHeaders :: Invoke -> [Header] #

ToPath Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

toPath :: Invoke -> ByteString #

ToQuery Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

NFData Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

rnf :: Invoke -> () #

type Rep Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

type Rs Invoke Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Request Lenses

iInvocationType :: Lens' Invoke (Maybe InvocationType) Source #

By default, the Invoke API assumes RequestResponse invocation type. You can optionally request asynchronous execution by specifying Event as the InvocationType . You can also use this parameter to request AWS Lambda to not execute the function but do some verification, such as if the caller is authorized to invoke the function and if the inputs are valid. You request this by specifying DryRun as the InvocationType . This is useful in a cross-account scenario when you want to verify access to a function without running it.

iLogType :: Lens' Invoke (Maybe LogType) Source #

You can set this optional parameter to Tail in the request only if you specify the InvocationType parameter with value RequestResponse . In this case, AWS Lambda returns the base64-encoded last 4 KB of log data produced by your Lambda function in the x-amz-log-result header.

iQualifier :: Lens' Invoke (Maybe Text) Source #

You can use this optional parameter to specify a Lambda function version or alias name. If you specify a function version, the API uses the qualified function ARN to invoke a specific Lambda function. If you specify an alias name, the API uses the alias ARN to invoke the Lambda function version to which the alias points. If you don't provide this parameter, then the API uses unqualified function ARN which results in invocation of the > LATEST version.

iClientContext :: Lens' Invoke (Maybe Text) Source #

Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, see PutEvents in the Amazon Mobile Analytics API Reference and User Guide . The ClientContext JSON must be base64-encoded and has a maximum size of 3583 bytes.

iFunctionName :: Lens' Invoke Text Source #

The Lambda function name. You can specify a function name (for example, Thumbnail ) or you can specify Amazon Resource Name (ARN) of the function (for example, arn:aws:lambda:us-west-2:account-id:function:ThumbNail ). AWS Lambda also allows you to specify a partial ARN (for example, account-id:Thumbnail ). Note that the length constraint applies only to the ARN. If you specify only the function name, it is limited to 64 characters in length.

iPayload :: Lens' Invoke ByteString Source #

JSON that you want to provide to your Lambda function as input.

Destructuring the Response

invokeResponse Source #

Creates a value of InvokeResponse with the minimum fields required to make a request.

Use one of the following lenses to modify other fields as desired:

  • irsFunctionError - Indicates whether an error occurred while executing the Lambda function. If an error occurred this field will have one of two values; Handled or Unhandled . Handled errors are errors that are reported by the function while the Unhandled errors are those detected and reported by AWS Lambda. Unhandled errors include out of memory errors and function timeouts. For information about how to report an Handled error, see Programming Model .
  • irsLogResult - It is the base64-encoded logs for the Lambda function invocation. This is present only if the invocation type is RequestResponse and the logs were requested.
  • irsPayload - It is the JSON representation of the object returned by the Lambda function. This is present only if the invocation type is RequestResponse . In the event of a function error this field contains a message describing the error. For the Handled errors the Lambda function will report this message. For Unhandled errors AWS Lambda reports the message.
  • irsExecutedVersion - The function version that has been executed. This value is returned only if the invocation type is RequestResponse . For more information, see 'lambda-traffic-shifting-using-aliases' .
  • irsStatusCode - The HTTP status code will be in the 200 range for successful request. For the RequestResponse invocation type this status code will be 200. For the Event invocation type this status code will be 202. For the DryRun invocation type the status code will be 204.

data InvokeResponse Source #

Upon success, returns an empty response. Otherwise, throws an exception.

See: invokeResponse smart constructor.

Instances
Eq InvokeResponse Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Data InvokeResponse Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> InvokeResponse -> c InvokeResponse #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c InvokeResponse #

toConstr :: InvokeResponse -> Constr #

dataTypeOf :: InvokeResponse -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c InvokeResponse) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c InvokeResponse) #

gmapT :: (forall b. Data b => b -> b) -> InvokeResponse -> InvokeResponse #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> InvokeResponse -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> InvokeResponse -> r #

gmapQ :: (forall d. Data d => d -> u) -> InvokeResponse -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> InvokeResponse -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> InvokeResponse -> m InvokeResponse #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> InvokeResponse -> m InvokeResponse #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> InvokeResponse -> m InvokeResponse #

Show InvokeResponse Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Generic InvokeResponse Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Associated Types

type Rep InvokeResponse :: Type -> Type #

NFData InvokeResponse Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

Methods

rnf :: InvokeResponse -> () #

type Rep InvokeResponse Source # 
Instance details

Defined in Network.AWS.Lambda.Invoke

type Rep InvokeResponse = D1 (MetaData "InvokeResponse" "Network.AWS.Lambda.Invoke" "amazonka-lambda-1.6.1-KQvkrTCQjBWL6Bwjq8xw0f" False) (C1 (MetaCons "InvokeResponse'" PrefixI True) ((S1 (MetaSel (Just "_irsFunctionError") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Text)) :*: S1 (MetaSel (Just "_irsLogResult") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 (MetaSel (Just "_irsPayload") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString)) :*: (S1 (MetaSel (Just "_irsExecutedVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Text)) :*: S1 (MetaSel (Just "_irsStatusCode") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int)))))

Response Lenses

irsFunctionError :: Lens' InvokeResponse (Maybe Text) Source #

Indicates whether an error occurred while executing the Lambda function. If an error occurred this field will have one of two values; Handled or Unhandled . Handled errors are errors that are reported by the function while the Unhandled errors are those detected and reported by AWS Lambda. Unhandled errors include out of memory errors and function timeouts. For information about how to report an Handled error, see Programming Model .

irsLogResult :: Lens' InvokeResponse (Maybe Text) Source #

It is the base64-encoded logs for the Lambda function invocation. This is present only if the invocation type is RequestResponse and the logs were requested.

irsPayload :: Lens' InvokeResponse (Maybe ByteString) Source #

It is the JSON representation of the object returned by the Lambda function. This is present only if the invocation type is RequestResponse . In the event of a function error this field contains a message describing the error. For the Handled errors the Lambda function will report this message. For Unhandled errors AWS Lambda reports the message.

irsExecutedVersion :: Lens' InvokeResponse (Maybe Text) Source #

The function version that has been executed. This value is returned only if the invocation type is RequestResponse . For more information, see 'lambda-traffic-shifting-using-aliases' .

irsStatusCode :: Lens' InvokeResponse Int Source #

The HTTP status code will be in the 200 range for successful request. For the RequestResponse invocation type this status code will be 200. For the Event invocation type this status code will be 202. For the DryRun invocation type the status code will be 204.