AWS Elastic Load Balancing Backend Server Policy

This page shows how to write Terraform and CloudFormation for Elastic Load Balancing Backend Server Policy and write them securely.

aws_load_balancer_backend_server_policy (Terraform)

The Backend Server Policy in Elastic Load Balancing can be configured in Terraform with the resource name aws_load_balancer_backend_server_policy. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L7
resource "aws_load_balancer_backend_server_policy" "this" {
  instance_port      = var.instance_port
  load_balancer_name = var.load_balancer_name
  policy_names       = var.policy_names
}

load_balancer_backend_server_policy.tf#L4
resource "aws_load_balancer_backend_server_policy" "load_balancer_backend_server_policy" {
  count = var.enable_load_balancer_backend_server_policy ? 1 : 0

  load_balancer_name = var.load_balancer_backend_server_policy_load_balancer_name != "" ? var.load_balancer_backend_server_policy_load_balancer_name : (var.enable_elb ? aws_elb.elb[0].name : null)
  instance_port      = var.load_balancer_backend_server_policy_instance_port
  policy_names       = coalescelist(var.load_balancer_backend_server_policy_policy_names, aws_load_balancer_policy.load_balancer_policy[0].policy_name)
load_balancer_backend_server_policy.tf#L4
resource "aws_load_balancer_backend_server_policy" "load_balancer_backend_server_policy" {
  count = var.enable_load_balancer_backend_server_policy ? 1 : 0

  load_balancer_name = var.load_balancer_backend_server_policy_load_balancer_name != "" ? var.load_balancer_backend_server_policy_load_balancer_name : (var.enable_elb ? aws_elb.elb[0].name : null)
  instance_port      = var.load_balancer_backend_server_policy_instance_port
  policy_names       = coalescelist(var.load_balancer_backend_server_policy_policy_names, aws_load_balancer_policy.load_balancer_policy[0].policy_name)
negative.tf#L68
resource "aws_load_balancer_backend_server_policy" "negative6" {
  load_balancer_name = aws_elb.wu-tang.name
  instance_port      = 443

  policy_names = [
    aws_load_balancer_policy.wu-tang-root-ca-backend-auth-policy.policy_name,
negative.tf#L68
resource "aws_load_balancer_backend_server_policy" "negative6" {
  load_balancer_name = aws_elb.wu-tang.name
  instance_port      = 443

  policy_names = [
    aws_load_balancer_policy.wu-tang-root-ca-backend-auth-policy.policy_name,

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Attaches a load balancer policy to an ELB backend server.

Tips: Best Practices for The Other AWS Elastic Load Balancing Resources

In addition to the aws_elb, AWS Elastic Load Balancing has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

aws_elb

Ensure your ALB blocks unwanted access

It is better to limit accessibility to the minimum that is required for the application to work.

Review your AWS Elastic Load Balancing settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

AWS::ElasticLoadBalancing::LoadBalancer Policies (CloudFormation)

The LoadBalancer Policies in ElasticLoadBalancing can be configured in CloudFormation with the resource name AWS::ElasticLoadBalancing::LoadBalancer Policies. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Parameters

Attributes The policy attributes.
Required: Yes
Type: List of Json
Update requires: No interruption

InstancePorts The instance ports for the policy. Required only for some policy types.
Required: No
Type: List of String
Update requires: No interruption

LoadBalancerPorts The load balancer ports for the policy. Required only for some policy types.
Required: No
Type: List of String
Update requires: No interruption

PolicyName The name of the policy.
Required: Yes
Type: String
Update requires: No interruption

PolicyType The name of the policy type.
Required: Yes
Type: String
Update requires: No interruption

Explanation in CloudFormation Registry

Specifies policies for your Classic Load Balancer.

To associate policies with a listener, use the PolicyNames property for the listener.

Frequently asked questions

What is AWS Elastic Load Balancing Backend Server Policy?

AWS Elastic Load Balancing Backend Server Policy is a resource for Elastic Load Balancing of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Elastic Load Balancing Backend Server Policy?

For Terraform, the niveklabs/aws, asrkata/SebastianUA-terraform and SebastianUA/terraform source code examples are useful. See the Terraform Example section for further details.