AWS Lambda

2017/11/29 - AWS Lambda - 5 updated api methods

Changes  Lambda aliases can now shift traffic between two function versions, based on preassigned weights.

CreateAlias (updated) Link ¶
Changes (both)
{'RoutingConfig': {'AdditionalVersionWeights': {'string': 'double'}}}

Creates an alias that points to the specified Lambda function version. For more information, see Introduction to AWS Lambda Aliases .

Alias names are unique for a given function. This requires permission for the lambda:CreateAlias action.

See also: AWS API Documentation

Request Syntax

client.create_alias(
    FunctionName='string',
    Name='string',
    FunctionVersion='string',
    Description='string',
    RoutingConfig={
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    }
)
type FunctionName

string

param FunctionName

[REQUIRED]

Name of the Lambda function for which you want to create an alias. 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.

type Name

string

param Name

[REQUIRED]

Name for the alias you are creating.

type FunctionVersion

string

param FunctionVersion

[REQUIRED]

Lambda function version for which you are creating the alias.

type Description

string

param Description

Description of the alias.

type RoutingConfig

dict

param RoutingConfig

Specifies an additional version your alias can point to, allowing you to dictate what percentage of traffic will invoke each version. For more information, see lambda-traffic-shifting-using-aliases .

  • AdditionalVersionWeights (dict) --

    Set this property value to dictate what percentage of traffic will invoke the updated function version. If set to an empty string, 100 percent of traffic will invoke function-version .

    • (string) --

      • (float) --

rtype

dict

returns

Response Syntax

{
    'AliasArn': 'string',
    'Name': 'string',
    'FunctionVersion': 'string',
    'Description': 'string',
    'RoutingConfig': {
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    }
}

Response Structure

  • (dict) --

    Provides configuration information about a Lambda function version alias.

    • AliasArn (string) --

      Lambda function ARN that is qualified using the alias name as the suffix. For example, if you create an alias called BETA that points to a helloworld function version, the ARN is arn:aws:lambda:aws-regions:acct-id:function:helloworld:BETA .

    • Name (string) --

      Alias name.

    • FunctionVersion (string) --

      Function version to which the alias points.

    • Description (string) --

      Alias description.

    • RoutingConfig (dict) --

      Specifies an additional function versions the alias points to, allowing you to dictate what percentage of traffic will invoke each version. For more information, see lambda-traffic-shifting-using-aliases .

      • AdditionalVersionWeights (dict) --

        Set this property value to dictate what percentage of traffic will invoke the updated function version. If set to an empty string, 100 percent of traffic will invoke function-version .

        • (string) --

          • (float) --

GetAlias (updated) Link ¶
Changes (response)
{'RoutingConfig': {'AdditionalVersionWeights': {'string': 'double'}}}

Returns the specified alias information such as the alias ARN, description, and function version it is pointing to. For more information, see Introduction to AWS Lambda Aliases .

This requires permission for the lambda:GetAlias action.

See also: AWS API Documentation

Request Syntax

client.get_alias(
    FunctionName='string',
    Name='string'
)
type FunctionName

string

param FunctionName

[REQUIRED]

Function name for which the alias is created. An alias is a subresource that exists only in the context of an existing Lambda function so you must specify the function name. 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.

type Name

string

param Name

[REQUIRED]

Name of the alias for which you want to retrieve information.

rtype

dict

returns

Response Syntax

{
    'AliasArn': 'string',
    'Name': 'string',
    'FunctionVersion': 'string',
    'Description': 'string',
    'RoutingConfig': {
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    }
}

Response Structure

  • (dict) --

    Provides configuration information about a Lambda function version alias.

    • AliasArn (string) --

      Lambda function ARN that is qualified using the alias name as the suffix. For example, if you create an alias called BETA that points to a helloworld function version, the ARN is arn:aws:lambda:aws-regions:acct-id:function:helloworld:BETA .

    • Name (string) --

      Alias name.

    • FunctionVersion (string) --

      Function version to which the alias points.

    • Description (string) --

      Alias description.

    • RoutingConfig (dict) --

      Specifies an additional function versions the alias points to, allowing you to dictate what percentage of traffic will invoke each version. For more information, see lambda-traffic-shifting-using-aliases .

      • AdditionalVersionWeights (dict) --

        Set this property value to dictate what percentage of traffic will invoke the updated function version. If set to an empty string, 100 percent of traffic will invoke function-version .

        • (string) --

          • (float) --

Invoke (updated) Link ¶
Changes (response)
{'ExecutedVersion': 'string'}

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.

See also: AWS API Documentation

Request Syntax

client.invoke(
    FunctionName='string',
    InvocationType='Event'|'RequestResponse'|'DryRun',
    LogType='None'|'Tail',
    ClientContext='string',
    Payload=b'bytes'|file,
    Qualifier='string'
)
type FunctionName

string

param FunctionName

[REQUIRED]

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.

type InvocationType

string

param InvocationType

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.

type LogType

string

param LogType

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.

type ClientContext

string

param ClientContext

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.

type Payload

bytes or seekable file-like object

param Payload

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

type Qualifier

string

param Qualifier

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.

rtype

dict

returns

Response Syntax

{
    'StatusCode': 123,
    'FunctionError': 'string',
    'LogResult': 'string',
    'Payload': b'bytes'|file,
    'ExecutedVersion': 'string'
}

Response Structure

  • (dict) --

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

    • StatusCode (integer) --

      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.

    • FunctionError (string) --

      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 .

    • LogResult (string) --

      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.

    • Payload (bytes or seekable file-like object) --

      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.

    • ExecutedVersion (string) --

      The function version that has been executed. This value is returned only if the invocation type is RequestResponse .

ListAliases (updated) Link ¶
Changes (response)
{'Aliases': {'RoutingConfig': {'AdditionalVersionWeights': {'string': 'double'}}}}

Returns list of aliases created for a Lambda function. For each alias, the response includes information such as the alias ARN, description, alias name, and the function version to which it points. For more information, see Introduction to AWS Lambda Aliases .

This requires permission for the lambda:ListAliases action.

See also: AWS API Documentation

Request Syntax

client.list_aliases(
    FunctionName='string',
    FunctionVersion='string',
    Marker='string',
    MaxItems=123
)
type FunctionName

string

param FunctionName

[REQUIRED]

Lambda function name for which the alias is created. 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.

type FunctionVersion

string

param FunctionVersion

If you specify this optional parameter, the API returns only the aliases that are pointing to the specific Lambda function version, otherwise the API returns all of the aliases created for the Lambda function.

type Marker

string

param Marker

Optional string. An opaque pagination token returned from a previous ListAliases operation. If present, indicates where to continue the listing.

type MaxItems

integer

param MaxItems

Optional integer. Specifies the maximum number of aliases to return in response. This parameter value must be greater than 0.

rtype

dict

returns

Response Syntax

{
    'NextMarker': 'string',
    'Aliases': [
        {
            'AliasArn': 'string',
            'Name': 'string',
            'FunctionVersion': 'string',
            'Description': 'string',
            'RoutingConfig': {
                'AdditionalVersionWeights': {
                    'string': 123.0
                }
            }
        },
    ]
}

Response Structure

  • (dict) --

    • NextMarker (string) --

      A string, present if there are more aliases.

    • Aliases (list) --

      A list of aliases.

      • (dict) --

        Provides configuration information about a Lambda function version alias.

        • AliasArn (string) --

          Lambda function ARN that is qualified using the alias name as the suffix. For example, if you create an alias called BETA that points to a helloworld function version, the ARN is arn:aws:lambda:aws-regions:acct-id:function:helloworld:BETA .

        • Name (string) --

          Alias name.

        • FunctionVersion (string) --

          Function version to which the alias points.

        • Description (string) --

          Alias description.

        • RoutingConfig (dict) --

          Specifies an additional function versions the alias points to, allowing you to dictate what percentage of traffic will invoke each version. For more information, see lambda-traffic-shifting-using-aliases .

          • AdditionalVersionWeights (dict) --

            Set this property value to dictate what percentage of traffic will invoke the updated function version. If set to an empty string, 100 percent of traffic will invoke function-version .

            • (string) --

              • (float) --

UpdateAlias (updated) Link ¶
Changes (both)
{'RoutingConfig': {'AdditionalVersionWeights': {'string': 'double'}}}

Using this API you can update the function version to which the alias points and the alias description. For more information, see Introduction to AWS Lambda Aliases .

This requires permission for the lambda:UpdateAlias action.

See also: AWS API Documentation

Request Syntax

client.update_alias(
    FunctionName='string',
    Name='string',
    FunctionVersion='string',
    Description='string',
    RoutingConfig={
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    }
)
type FunctionName

string

param FunctionName

[REQUIRED]

The function name for which the alias is created. 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.

type Name

string

param Name

[REQUIRED]

The alias name.

type FunctionVersion

string

param FunctionVersion

Using this parameter you can change the Lambda function version to which the alias points.

type Description

string

param Description

You can change the description of the alias using this parameter.

type RoutingConfig

dict

param RoutingConfig

Specifies an additional version your alias can point to, allowing you to dictate what percentage of traffic will invoke each version. For more information, see lambda-traffic-shifting-using-aliases .

  • AdditionalVersionWeights (dict) --

    Set this property value to dictate what percentage of traffic will invoke the updated function version. If set to an empty string, 100 percent of traffic will invoke function-version .

    • (string) --

      • (float) --

rtype

dict

returns

Response Syntax

{
    'AliasArn': 'string',
    'Name': 'string',
    'FunctionVersion': 'string',
    'Description': 'string',
    'RoutingConfig': {
        'AdditionalVersionWeights': {
            'string': 123.0
        }
    }
}

Response Structure

  • (dict) --

    Provides configuration information about a Lambda function version alias.

    • AliasArn (string) --

      Lambda function ARN that is qualified using the alias name as the suffix. For example, if you create an alias called BETA that points to a helloworld function version, the ARN is arn:aws:lambda:aws-regions:acct-id:function:helloworld:BETA .

    • Name (string) --

      Alias name.

    • FunctionVersion (string) --

      Function version to which the alias points.

    • Description (string) --

      Alias description.

    • RoutingConfig (dict) --

      Specifies an additional function versions the alias points to, allowing you to dictate what percentage of traffic will invoke each version. For more information, see lambda-traffic-shifting-using-aliases .

      • AdditionalVersionWeights (dict) --

        Set this property value to dictate what percentage of traffic will invoke the updated function version. If set to an empty string, 100 percent of traffic will invoke function-version .

        • (string) --

          • (float) --