AWS Elastic Load Balancing V2 Listener
This page shows how to write Terraform and CloudFormation for Elastic Load Balancing V2 Listener and write them securely.
aws_lb_listener (Terraform)
The Listener in Elastic Load Balancing V2 can be configured in Terraform with the resource name aws_lb_listener. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_lb_listener" "http_redirect" {
load_balancer_arn = var.aws_lb_arn
protocol = "HTTP"
port = "80"
default_action {
resource "aws_lb_listener" "listener_good_1" {
load_balancer_arn = aws_lb.lb_good_1.arn
port = "443"
protocol = "HTTPS"
default_action {
resource "aws_lb_listener" "http_redirect" {
load_balancer_arn = var.aws_lb_arn
# ok: insecure-load-balancer-tls-version
protocol = "HTTP"
port = "80"
resource "aws_lb_listener" "http_redirect" {
load_balancer_arn = var.aws_lb_arn
protocol = "HTTP"
port = "80"
default_action {
Parameters
-
alpn_policyoptional - string -
arnoptional computed - string -
certificate_arnoptional - string -
idoptional computed - string -
load_balancer_arnrequired - string -
portoptional - number -
protocoloptional computed - string -
ssl_policyoptional computed - string -
default_actionlist block-
orderoptional computed - number -
target_group_arnoptional - string -
typerequired - string -
authenticate_cognitolist block-
authentication_request_extra_paramsoptional - map from string to string -
on_unauthenticated_requestoptional computed - string -
scopeoptional computed - string -
session_cookie_nameoptional computed - string -
session_timeoutoptional computed - number -
user_pool_arnrequired - string -
user_pool_client_idrequired - string -
user_pool_domainrequired - string
-
-
authenticate_oidclist block-
authentication_request_extra_paramsoptional - map from string to string -
authorization_endpointrequired - string -
client_idrequired - string -
client_secretrequired - string -
issuerrequired - string -
on_unauthenticated_requestoptional computed - string -
scopeoptional computed - string -
session_cookie_nameoptional computed - string -
session_timeoutoptional computed - number -
token_endpointrequired - string -
user_info_endpointrequired - string
-
-
fixed_responselist block-
content_typerequired - string -
message_bodyoptional - string -
status_codeoptional computed - string
-
-
forwardlist block-
stickinesslist block -
target_groupset block
-
-
redirectlist block
-
-
timeoutssingle block-
readoptional - string
-
Explanation in Terraform Registry
Provides a Load Balancer Listener resource.
Note:
aws_alb_listeneris known asaws_lb_listener. The functionality is identical.
AWS::ElasticLoadBalancingV2::Listener (CloudFormation)
The Listener in ElasticLoadBalancingV2 can be configured in CloudFormation with the resource name AWS::ElasticLoadBalancingV2::Listener. 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
-
SslPolicyoptional - String -
LoadBalancerArnrequired - String -
DefaultActionsrequired - List of Action -
Portoptional - Integer -
Certificatesoptional - List of Certificate -
Protocoloptional - String -
AlpnPolicyoptional - List
Explanation in CloudFormation Registry
Specifies a listener for an Application Load Balancer or Network Load Balancer.
Frequently asked questions
What is AWS Elastic Load Balancing V2 Listener?
AWS Elastic Load Balancing V2 Listener is a resource for Elastic Load Balancing V2 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 V2 Listener?
For Terraform, the melscoop-test/check, melscoop-test/check and returntocorp/semgrep-rules source code examples are useful. See the Terraform Example section for further details.