AWS Elastic Load Balancing Listener Policy
This page shows how to write Terraform and CloudFormation for Elastic Load Balancing Listener Policy and write them securely.
aws_load_balancer_listener_policy (Terraform)
The Listener Policy in Elastic Load Balancing can be configured in Terraform with the resource name aws_load_balancer_listener_policy
. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_load_balancer_listener_policy" "load_balancer_listener_policy" {
count = var.enable_load_balancer_listener_policy ? 1 : 0
load_balancer_name = var.load_balancer_listener_policy_load_balancer_name != "" ? var.load_balancer_listener_policy_load_balancer_name : (var.enable_elb ? aws_elb.elb[0].name : null)
load_balancer_port = var.load_balancer_listener_policy_load_balancer_port
policy_names = coalescelist(var.load_balancer_listener_policy_policy_names, aws_load_balancer_policy.load_balancer_policy[0].policy_name)
resource "aws_load_balancer_listener_policy" "load_balancer_listener_policy" {
count = var.enable_load_balancer_listener_policy ? 1 : 0
load_balancer_name = var.load_balancer_listener_policy_load_balancer_name != "" ? var.load_balancer_listener_policy_load_balancer_name : (var.enable_elb ? aws_elb.elb[0].name : null)
load_balancer_port = var.load_balancer_listener_policy_load_balancer_port
policy_names = coalescelist(var.load_balancer_listener_policy_policy_names, aws_load_balancer_policy.load_balancer_policy[0].policy_name)
resource "aws_load_balancer_listener_policy" "this" {
load_balancer_name = var.load_balancer_name
load_balancer_port = var.load_balancer_port
policy_names = var.policy_names
}
resource "aws_load_balancer_listener_policy" "negative7" {
load_balancer_name = aws_elb.wu-tang.name
load_balancer_port = 443
policy_names = [
aws_load_balancer_policy.wu-tang-ssl.policy_name,
Parameters
-
id
optional computed - string -
load_balancer_name
required - string -
load_balancer_port
required - number -
policy_names
optional - set of string
Explanation in Terraform Registry
Attaches a load balancer policy to an ELB Listener.
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.
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.
AWS::ElasticLoadBalancing::LoadBalancer Listeners (CloudFormation)
The LoadBalancer Listeners in ElasticLoadBalancing can be configured in CloudFormation with the resource name AWS::ElasticLoadBalancing::LoadBalancer Listeners
. 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
InstancePort
The port on which the instance is listening.
Required: Yes
Type: String
Minimum: 1
Maximum: 65535
Update requires: No interruption
InstanceProtocol
The protocol to use for routing traffic to instances: HTTP, HTTPS, TCP, or SSL.
If the front-end protocol is TCP or SSL, the back-end protocol must be TCP or SSL. If the front-end protocol is HTTP or HTTPS, the back-end protocol must be HTTP or HTTPS.
If there is another listener with the same InstancePort
whose InstanceProtocol
is secure, (HTTPS or SSL), the listener's InstanceProtocol
must also be secure.
If there is another listener with the same InstancePort
whose InstanceProtocol
is HTTP or TCP, the listener's InstanceProtocol
must be HTTP or TCP.
Required: No
Type: String
Update requires: No interruption
LoadBalancerPort
The port on which the load balancer is listening. On EC2-VPC, you can specify any port from the range 1-65535. On EC2-Classic, you can specify any port from the following list: 25, 80, 443, 465, 587, 1024-65535.
Required: Yes
Type: String
Update requires: No interruption
PolicyNames
The names of the policies to associate with the listener.
Required: No
Type: List of String
Update requires: No interruption
Protocol
The load balancer transport protocol to use for routing: HTTP, HTTPS, TCP, or SSL.
Required: Yes
Type: String
Update requires: No interruption
SSLCertificateId
The Amazon Resource Name (ARN) of the server certificate.
Required: No
Type: String
Update requires: No interruption
Explanation in CloudFormation Registry
Specifies a listener for your Classic Load Balancer.
Frequently asked questions
What is AWS Elastic Load Balancing Listener Policy?
AWS Elastic Load Balancing Listener 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 Listener Policy?
For Terraform, the asrkata/SebastianUA-terraform, SebastianUA/terraform and niveklabs/aws source code examples are useful. See the Terraform Example section for further details.