:doc:`ElasticLoadBalancing <../../elb>` / Client / create_load_balancer_policy

***************************
create_load_balancer_policy
***************************



.. py:method:: 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 <https://docs.aws.amazon.com/goto/WebAPI/elasticloadbalancing-2012-06-01/CreateLoadBalancerPolicy>`_  


  **Request Syntax**
  ::

    response = client.create_load_balancer_policy(
        LoadBalancerName='string',
        PolicyName='string',
        PolicyTypeName='string',
        PolicyAttributes=[
            {
                'AttributeName': 'string',
                'AttributeValue': 'string'
            },
        ]
    )
    
  :type LoadBalancerName: string
  :param LoadBalancerName: **[REQUIRED]** 

    The name of the load balancer.

    

  
  :type PolicyName: string
  :param PolicyName: **[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.

    

  
  :type PolicyTypeName: string
  :param PolicyTypeName: **[REQUIRED]** 

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

    

  
  :type PolicyAttributes: list
  :param PolicyAttributes: 

    The policy attributes.

    

  
    - *(dict) --* 

      Information about a policy attribute.

      

    
      - **AttributeName** *(string) --* 

        The name of the attribute.

        

      
      - **AttributeValue** *(string) --* 

        The value of the attribute.

        

      
    

  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 

      Contains the output of CreateLoadBalancerPolicy.

      
  
  **Exceptions**
  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.AccessPointNotFoundException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.PolicyTypeNotFoundException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.DuplicatePolicyNameException`

  
  *   :py:class:`ElasticLoadBalancing.Client.exceptions.TooManyPoliciesException`

  
  *   :py:class:`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': {
            '...': '...',
        },
    }

  