Lambda / Client / put_public_access_block_config

put_public_access_block_config#

Lambda.Client.put_public_access_block_config(**kwargs)#

Note

The option to configure public-access settings, and to use the PutPublicAccessBlock and GetPublicAccessBlock APIs, won’t be available in all Amazon Web Services Regions until September 30, 2024.

Configure your function’s public-access settings.

To control public access to a Lambda function, you can choose whether to allow the creation of resource-based policies that allow public access to that function. You can also block public access to a function, even if it has an existing resource-based policy that allows it.

See also: AWS API Documentation

Request Syntax

response = client.put_public_access_block_config(
    ResourceArn='string',
    PublicAccessBlockConfig={
        'BlockPublicPolicy': True|False,
        'RestrictPublicResource': True|False
    }
)
Parameters:
  • ResourceArn (string) –

    [REQUIRED]

    The Amazon Resource Name (ARN) of the function you want to configure public-access settings for. Public-access settings are applied at the function level, so you can’t apply different settings to function versions or aliases.

  • PublicAccessBlockConfig (dict) –

    [REQUIRED]

    An object defining the public-access settings you want to apply.

    To block the creation of resource-based policies that would grant public access to your function, set BlockPublicPolicy to true. To allow the creation of resource-based policies that would grant public access to your function, set BlockPublicPolicy to false.

    To block public access to your function, even if its resource-based policy allows it, set RestrictPublicResource to true. To allow public access to a function with a resource-based policy that permits it, set RestrictPublicResource to false.

    The default setting for both BlockPublicPolicy and RestrictPublicResource is true.

    • BlockPublicPolicy (boolean) –

      To block the creation of resource-based policies that would grant public access to your function, set BlockPublicPolicy to true. To allow the creation of resource-based policies that would grant public access to your function, set BlockPublicPolicy to false.

    • RestrictPublicResource (boolean) –

      To block public access to your function, even if its resource-based policy allows it, set RestrictPublicResource to true. To allow public access to a function with a resource-based policy that permits it, set RestrictPublicResource to false.

Return type:

dict

Returns:

Response Syntax

{
    'PublicAccessBlockConfig': {
        'BlockPublicPolicy': True|False,
        'RestrictPublicResource': True|False
    }
}

Response Structure

  • (dict) –

    • PublicAccessBlockConfig (dict) –

      The public-access settings Lambda applied to your function.

      • BlockPublicPolicy (boolean) –

        To block the creation of resource-based policies that would grant public access to your function, set BlockPublicPolicy to true. To allow the creation of resource-based policies that would grant public access to your function, set BlockPublicPolicy to false.

      • RestrictPublicResource (boolean) –

        To block public access to your function, even if its resource-based policy allows it, set RestrictPublicResource to true. To allow public access to a function with a resource-based policy that permits it, set RestrictPublicResource to false.

Exceptions

  • Lambda.Client.exceptions.ServiceException

  • Lambda.Client.exceptions.ResourceNotFoundException

  • Lambda.Client.exceptions.ResourceConflictException

  • Lambda.Client.exceptions.InvalidParameterValueException

  • Lambda.Client.exceptions.TooManyRequestsException