ElasticLoadBalancing / Client / create_load_balancer_policy

create_load_balancer_policy#

ElasticLoadBalancing.Client.create_load_balancer_policy(**kwargs)#

Creates a policy with the specified attributes for the specified load balancer.

Policies are settings that are saved for your load balancer and that can be applied to the listener or the application server, depending on the policy type.

See also: AWS API Documentation

Request Syntax

response = client.create_load_balancer_policy(
    LoadBalancerName='string',
    PolicyName='string',
    PolicyTypeName='string',
    PolicyAttributes=[
        {
            'AttributeName': 'string',
            'AttributeValue': 'string'
        },
    ]
)
Parameters:
  • LoadBalancerName (string) –

    [REQUIRED]

    The name of the load balancer.

  • PolicyName (string) –

    [REQUIRED]

    The name of the load balancer policy to be created. This name must be unique within the set of policies for this load balancer.

  • PolicyTypeName (string) –

    [REQUIRED]

    The name of the base policy type. To get the list of policy types, use DescribeLoadBalancerPolicyTypes.

  • PolicyAttributes (list) –

    The policy attributes.

    • (dict) –

      Information about a policy attribute.

      • AttributeName (string) –

        The name of the attribute.

      • AttributeValue (string) –

        The value of the attribute.

Return type:

dict

Returns:

Response Syntax

{}

Response Structure

  • (dict) –

    Contains the output of CreateLoadBalancerPolicy.

Exceptions

  • ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException

  • ElasticLoadBalancing.Client.exceptions.PolicyTypeNotFoundException

  • ElasticLoadBalancing.Client.exceptions.DuplicatePolicyNameException

  • ElasticLoadBalancing.Client.exceptions.TooManyPoliciesException

  • ElasticLoadBalancing.Client.exceptions.InvalidConfigurationRequestException

Examples

This example creates a policy that enables Proxy Protocol on the specified load balancer.

response = client.create_load_balancer_policy(
    LoadBalancerName='my-load-balancer',
    PolicyAttributes=[
        {
            'AttributeName': 'ProxyProtocol',
            'AttributeValue': 'true',
        },
    ],
    PolicyName='my-ProxyProtocol-policy',
    PolicyTypeName='ProxyProtocolPolicyType',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}

This example creates a public key policy.

response = client.create_load_balancer_policy(
    LoadBalancerName='my-load-balancer',
    PolicyAttributes=[
        {
            'AttributeName': 'PublicKey',
            'AttributeValue': 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwAYUjnfyEyXr1pxjhFWBpMlggUcqoi3kl+dS74kj//c6x7ROtusUaeQCTgIUkayttRDWchuqo1pHC1u+n5xxXnBBe2ejbb2WRsKIQ5rXEeixsjFpFsojpSQKkzhVGI6mJVZBJDVKSHmswnwLBdofLhzvllpovBPTHe+o4haAWvDBALJU0pkSI1FecPHcs2hwxf14zHoXy1e2k36A64nXW43wtfx5qcVSIxtCEOjnYRg7RPvybaGfQ+v6Iaxb/+7J5kEvZhTFQId+bSiJImF1FSUT1W1xwzBZPUbcUkkXDj45vC2s3Z8E+Lk7a3uZhvsQHLZnrfuWjBWGWvZ/MhZYgEXAMPLE',
        },
    ],
    PolicyName='my-PublicKey-policy',
    PolicyTypeName='PublicKeyPolicyType',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}

This example creates a backend server authentication policy that enables authentication on your backend instance using a public key policy.

response = client.create_load_balancer_policy(
    LoadBalancerName='my-load-balancer',
    PolicyAttributes=[
        {
            'AttributeName': 'PublicKeyPolicyName',
            'AttributeValue': 'my-PublicKey-policy',
        },
    ],
    PolicyName='my-authentication-policy',
    PolicyTypeName='BackendServerAuthenticationPolicyType',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}