getListener

Note: aws.alb.Listener is known as aws.lb.Listener. The functionality is identical.

Provides information about a Load Balancer Listener.

This data source can prove useful when a module accepts an LB Listener as an input variable and needs to know the LB it is attached to, or other information specific to the listener in question.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var listenerArn = config.Require("listenerArn");
    var listener = Aws.LB.GetListener.Invoke(new()
    {
        Arn = listenerArn,
    });

    var selected = Aws.LB.GetLoadBalancer.Invoke(new()
    {
        Name = "default-public",
    });

    var selected443 = Aws.LB.GetListener.Invoke(new()
    {
        LoadBalancerArn = selected.Apply(getLoadBalancerResult => getLoadBalancerResult.Arn),
        Port = 443,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lb"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		listenerArn := cfg.Require("listenerArn")
		_, err = lb.LookupListener(ctx, &lb.LookupListenerArgs{
			Arn: pulumi.StringRef(listenerArn),
		}, nil)
		if err != nil {
			return err
		}
		selected, err := lb.LookupLoadBalancer(ctx, &lb.LookupLoadBalancerArgs{
			Name: pulumi.StringRef("default-public"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = lb.LookupListener(ctx, &lb.LookupListenerArgs{
			LoadBalancerArn: pulumi.StringRef(selected.Arn),
			Port:            pulumi.IntRef(443),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lb.LbFunctions;
import com.pulumi.aws.alb.inputs.GetListenerArgs;
import com.pulumi.aws.alb.inputs.GetLoadBalancerArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var config = ctx.config();
        final var listenerArn = config.get("listenerArn");
        final var listener = LbFunctions.getListener(GetListenerArgs.builder()
            .arn(listenerArn)
            .build());

        final var selected = LbFunctions.getLoadBalancer(GetLoadBalancerArgs.builder()
            .name("default-public")
            .build());

        final var selected443 = LbFunctions.getListener(GetListenerArgs.builder()
            .loadBalancerArn(selected.applyValue(getLoadBalancerResult -> getLoadBalancerResult.arn()))
            .port(443)
            .build());

    }
}
import pulumi
import pulumi_aws as aws

config = pulumi.Config()
listener_arn = config.require("listenerArn")
listener = aws.lb.get_listener(arn=listener_arn)
selected = aws.lb.get_load_balancer(name="default-public")
selected443 = aws.lb.get_listener(load_balancer_arn=selected.arn,
    port=443)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const config = new pulumi.Config();
const listenerArn = config.require("listenerArn");
const listener = aws.lb.getListener({
    arn: listenerArn,
});
const selected = aws.lb.getLoadBalancer({
    name: "default-public",
});
const selected443 = selected.then(selected => aws.lb.getListener({
    loadBalancerArn: selected.arn,
    port: 443,
}));
configuration:
  # get listener from listener arn
  listenerArn:
    type: string
variables:
  listener: # get listener from load_balancer_arn and port
    fn::invoke:
      Function: aws:lb:getListener
      Arguments:
        arn: ${listenerArn}
  selected:
    fn::invoke:
      Function: aws:lb:getLoadBalancer
      Arguments:
        name: default-public
  selected443:
    fn::invoke:
      Function: aws:lb:getListener
      Arguments:
        loadBalancerArn: ${selected.arn}
        port: 443

Using getListener

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getListener(args: GetListenerArgs, opts?: InvokeOptions): Promise<GetListenerResult>
function getListenerOutput(args: GetListenerOutputArgs, opts?: InvokeOptions): Output<GetListenerResult>
def get_listener(arn: Optional[str] = None,
                 load_balancer_arn: Optional[str] = None,
                 port: Optional[int] = None,
                 tags: Optional[Mapping[str, str]] = None,
                 opts: Optional[InvokeOptions] = None) -> GetListenerResult
def get_listener_output(arn: Optional[pulumi.Input[str]] = None,
                 load_balancer_arn: Optional[pulumi.Input[str]] = None,
                 port: Optional[pulumi.Input[int]] = None,
                 tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetListenerResult]
func LookupListener(ctx *Context, args *LookupListenerArgs, opts ...InvokeOption) (*LookupListenerResult, error)
func LookupListenerOutput(ctx *Context, args *LookupListenerOutputArgs, opts ...InvokeOption) LookupListenerResultOutput

> Note: This function is named LookupListener in the Go SDK.

public static class GetListener 
{
    public static Task<GetListenerResult> InvokeAsync(GetListenerArgs args, InvokeOptions? opts = null)
    public static Output<GetListenerResult> Invoke(GetListenerInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetListenerResult> getListener(GetListenerArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: aws:lb/getListener:getListener
  arguments:
    # arguments dictionary

The following arguments are supported:

Arn string

ARN of the listener. Required if load_balancer_arn and port is not set.

LoadBalancerArn string

ARN of the load balancer. Required if arn is not set.

Port int

Port of the listener. Required if arn is not set.

Tags Dictionary<string, string>
Arn string

ARN of the listener. Required if load_balancer_arn and port is not set.

LoadBalancerArn string

ARN of the load balancer. Required if arn is not set.

Port int

Port of the listener. Required if arn is not set.

Tags map[string]string
arn String

ARN of the listener. Required if load_balancer_arn and port is not set.

loadBalancerArn String

ARN of the load balancer. Required if arn is not set.

port Integer

Port of the listener. Required if arn is not set.

tags Map<String,String>
arn string

ARN of the listener. Required if load_balancer_arn and port is not set.

loadBalancerArn string

ARN of the load balancer. Required if arn is not set.

port number

Port of the listener. Required if arn is not set.

tags {[key: string]: string}
arn str

ARN of the listener. Required if load_balancer_arn and port is not set.

load_balancer_arn str

ARN of the load balancer. Required if arn is not set.

port int

Port of the listener. Required if arn is not set.

tags Mapping[str, str]
arn String

ARN of the listener. Required if load_balancer_arn and port is not set.

loadBalancerArn String

ARN of the load balancer. Required if arn is not set.

port Number

Port of the listener. Required if arn is not set.

tags Map<String>

getListener Result

The following output properties are available:

AlpnPolicy string
Arn string
CertificateArn string
DefaultActions List<GetListenerDefaultAction>
Id string

The provider-assigned unique ID for this managed resource.

LoadBalancerArn string
Port int
Protocol string
SslPolicy string
Tags Dictionary<string, string>
AlpnPolicy string
Arn string
CertificateArn string
DefaultActions []GetListenerDefaultAction
Id string

The provider-assigned unique ID for this managed resource.

LoadBalancerArn string
Port int
Protocol string
SslPolicy string
Tags map[string]string
alpnPolicy String
arn String
certificateArn String
defaultActions List<GetListenerDefaultAction>
id String

The provider-assigned unique ID for this managed resource.

loadBalancerArn String
port Integer
protocol String
sslPolicy String
tags Map<String,String>
alpnPolicy string
arn string
certificateArn string
defaultActions GetListenerDefaultAction[]
id string

The provider-assigned unique ID for this managed resource.

loadBalancerArn string
port number
protocol string
sslPolicy string
tags {[key: string]: string}
alpn_policy str
arn str
certificate_arn str
default_actions Sequence[GetListenerDefaultAction]
id str

The provider-assigned unique ID for this managed resource.

load_balancer_arn str
port int
protocol str
ssl_policy str
tags Mapping[str, str]
alpnPolicy String
arn String
certificateArn String
defaultActions List<Property Map>
id String

The provider-assigned unique ID for this managed resource.

loadBalancerArn String
port Number
protocol String
sslPolicy String
tags Map<String>

Supporting Types

GetListenerDefaultAction

GetListenerDefaultActionAuthenticateCognito

GetListenerDefaultActionAuthenticateOidc

GetListenerDefaultActionFixedResponse

GetListenerDefaultActionForward

GetListenerDefaultActionForwardStickiness

duration Integer
enabled Boolean
duration number
enabled boolean
duration Number
enabled Boolean

GetListenerDefaultActionForwardTargetGroup

Arn string

ARN of the listener. Required if load_balancer_arn and port is not set.

Weight int
Arn string

ARN of the listener. Required if load_balancer_arn and port is not set.

Weight int
arn String

ARN of the listener. Required if load_balancer_arn and port is not set.

weight Integer
arn string

ARN of the listener. Required if load_balancer_arn and port is not set.

weight number
arn str

ARN of the listener. Required if load_balancer_arn and port is not set.

weight int
arn String

ARN of the listener. Required if load_balancer_arn and port is not set.

weight Number

GetListenerDefaultActionRedirect

Host string
Path string
Port string

Port of the listener. Required if arn is not set.

Protocol string
Query string
StatusCode string
Host string
Path string
Port string

Port of the listener. Required if arn is not set.

Protocol string
Query string
StatusCode string
host String
path String
port String

Port of the listener. Required if arn is not set.

protocol String
query String
statusCode String
host string
path string
port string

Port of the listener. Required if arn is not set.

protocol string
query string
statusCode string
host str
path str
port str

Port of the listener. Required if arn is not set.

protocol str
query str
status_code str
host String
path String
port String

Port of the listener. Required if arn is not set.

protocol String
query String
statusCode String

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.