There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CreateLoadBalancerPolicy with a CLI
The following code examples show how to use CreateLoadBalancerPolicy.
- CLI
-
- AWS CLI
-
Example 1: To create a policy that enables Proxy Protocol on a load balancer
The following
create-load-balancer-policyexample creates a policy that enables Proxy Protocol on the specified load balancer.aws elb create-load-balancer-policy \ --load-balancer-namemy-load-balancer\ --policy-namemy-ProxyProtocol-policy\ --policy-type-nameProxyProtocolPolicyType\ --policy-attributesAttributeName=ProxyProtocol,AttributeValue=trueThis command produces no output.
For more information, see Configure proxy protocol for your Classic Load Balancer in the Classic Load Balancers User Guide.
Example 2: To create an SSL negotiation policy using the recommended security policy
The following
create-load-balancer-policyexample creates an SSL negotiation policy for the specified HTTPS load balancer using the recommended security policy.aws elb create-load-balancer-policy \ --load-balancer-namemy-load-balancer\ --policy-namemy-SSLNegotiation-policy\ --policy-type-nameSSLNegotiationPolicyType\ --policy-attributesAttributeName=Reference-Security-Policy,AttributeValue=ELBSecurityPolicy-2015-03This command produces no output.
For more information, see SSL negotiation configurations for Classic Load Balancers in the Classic Load Balancers User Guide.
Example 3: To create an SSL negotiation policy using a custom security policy
The following
create-load-balancer-policyexample creates an SSL negotiation policy for your HTTPS load balancer using a custom security policy by enabling the protocols and the ciphers.aws elb create-load-balancer-policy \ --load-balancer-namemy-load-balancer\ --policy-namemy-SSLNegotiation-policy\ --policy-type-nameSSLNegotiationPolicyType\ --policy-attributesAttributeName=Protocol-SSLv3,AttributeValue=trueAttributeName=Protocol-TLSv1.1,AttributeValue=trueAttributeName=DHE-RSA-AES256-SHA256,AttributeValue=trueAttributeName=Server-Defined-Cipher-Order,AttributeValue=trueThis command produces no output.
For more information, see Update the SSL negotiation configuration of your Classic Load Balancer in the Classic Load Balancers User Guide.
Example 4: To create a public key policy
The following
create-load-balancer-policyexample creates a public key policy.aws elb create-load-balancer-policy \ --load-balancer-namemy-load-balancer\ --policy-namemy-PublicKey-policy\ --policy-type-namePublicKeyPolicyType\ --policy-attributesAttributeName=PublicKey,AttributeValue=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwAYUjnfyEyXr1pxjhFWBpMlggUcqoi3kl+dS74kj//c6x7ROtusUaeQCTgIUkayttRDWchuqo1pHC1u+n5xxXnBBe2ejbb2WRsKIQ5rXEeixsjFpFsojpSQKkzhVGI6mJVZBJDVKSHmswnwLBdofLhzvllpovBPTHe+o4haAWvDBALJU0pkSI1FecPHcs2hwxf14zHoXy1e2k36A64nXW43wtfx5qcVSIxtCEOjnYRg7RPvybaGfQ+v6Iaxb/+7J5kEvZhTFQId+bSiJImF1FSUT1W1xwzBZPUbcUkkXDj45vC2s3Z8E+Lk7a3uZhvsQHLZnrfuWjBWGWvZ/MhZYgEXAMPLEThis command produces no output.
For more information, see Create a Classic Load Balancer with an HTTPS listener in the Classic Load Balancers User Guide.
Example 5: To create a backend server authentication policy
The following
create-load-balancer-policyexample creates a backend server authentication policy that enables authentication on your backend instance using a public key policy.aws elb create-load-balancer-policy \ --load-balancer-namemy-load-balancer\ --policy-namemy-authentication-policy\ --policy-type-nameBackendServerAuthenticationPolicyType\ --policy-attributesAttributeName=PublicKeyPolicyName,AttributeValue=my-PublicKey-policyThis command produces no output.
For more information, see Create a Classic Load Balancer with an HTTPS listener in the Classic Load Balancers User Guide.
-
For API details, see CreateLoadBalancerPolicy
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example creates a new proxy protocol policy for a specified load balancer.
$attribute = New-Object Amazon.ElasticLoadBalancing.Model.PolicyAttribute -Property @{ AttributeName="ProxyProtocol" AttributeValue="True" } New-ELBLoadBalancerPolicy -LoadBalancerName my-load-balancer -PolicyName my-ProxyProtocol-policy -PolicyTypeName ProxyProtocolPolicyType -PolicyAttribute $attribute-
For API details, see CreateLoadBalancerPolicy in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example creates a new proxy protocol policy for a specified load balancer.
$attribute = New-Object Amazon.ElasticLoadBalancing.Model.PolicyAttribute -Property @{ AttributeName="ProxyProtocol" AttributeValue="True" } New-ELBLoadBalancerPolicy -LoadBalancerName my-load-balancer -PolicyName my-ProxyProtocol-policy -PolicyTypeName ProxyProtocolPolicyType -PolicyAttribute $attribute-
For API details, see CreateLoadBalancerPolicy in AWS Tools for PowerShell Cmdlet Reference (V5).
-