Elastic Load Balancing · Networking

Listener

Declare load balancer listeners and default actions.

Generic driverUniform lifecycle
Scope
Composite
Spec fields
10
Outputs
3
Lookup
Supported

Resource definition

What this resource looks like

This is the CUE shape a Praxis template uses to declare a Listener. The resource key is local to the template; metadata.name supplies its stable Praxis identity.

CUE example
resources: {
  httpsListener: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "Listener"
  	metadata: name: "\(variables.name)-\(variables.environment)-https"
  	spec: {
  		loadBalancerArn: variables.albArn
  		port:            443
  		protocol:        "HTTPS"
  		certificateArn:  "${resources.cert.outputs.certificateArn}"
  		defaultActions: [{
  			type:           "forward"
  			targetGroupArn: variables.targetGroupArn
  		}]
  		tags: {
  			app: variables.name
  			env: variables.environment
  		}
  	}
  }
}

Excerpted from examples/acm/https-stack.cue. Open the complete example for its variables and related resources.

Complete examples in the repository

Desired state

Configuration

The spec block accepts 10 fields. 5 are required by the schema; fields with defaults can be omitted.

accountOptional

Account.

string
String
regionOptional

Region.

string
String
loadBalancerArnRequired

Load Balancer ARN.

string
String
portRequired

Port.

int & >=1 & <=65535
Integer
protocolRequired

Protocol.

"HTTP" | "HTTPS" | "TCP" | "UDP" | "TLS" | "TCP_UDP"
Enum
sslPolicyOptional

Ssl Policy.

string
String
certificateArnOptional

Certificate ARN.

string
String
alpnPolicyOptional

Alpn Policy.

string
String
defaultActionsRequired

Default Actions.

[...#ListenerAction] & [_, ...]
List
tagsRequired

Tags.

[string]: string
Map

Observed values

Outputs

Praxis records these values after observation. A dependent resource can read one with ${resources.<name>.outputs.<field>}.

listenerArnString
portInteger
protocolString

Read without ownership

Data-source lookup

A data block reads an existing Listener and exposes its outputs without storing lifecycle state. The generic filter surface accepts id, name, and tag; supported combinations depend on the AWS identity used by this resource.

CUE data source
data: existing: {
  kind: "Listener"
  region: "us-west-2"
  filter: {
    name: "replace-with-provider-name"
  }
}

Understand data sources and filters →

Adopt existing infrastructure

Import

Import persists Praxis state for an existing AWS resource. For this kind, supply: Provider identifier for the existing Listener. The example starts in observed mode so Praxis reports drift without correcting it.

CLI
praxis import Listener \
  --id <provider-identifier> \
  --region us-west-2 \
  --account production \
  --observe

Choose managed or observed ownership →

Canonical contract

Complete CUE schema

The field guide above is derived from this definition. The schema remains the source of truth for accepted values, defaults, validation constraints, and outputs in the current alpha revision.

Show the complete schema
schemas/aws/elb/listener.cue
package elb

#Listener: {
	apiVersion: "praxis.io/alpha"
	kind:       "Listener"

	metadata: {
		name: string & =~"^[a-zA-Z0-9]([a-zA-Z0-9-]{0,30}[a-zA-Z0-9])?$"
		labels: [string]: string
	}

	spec: {
		account?:        string
		region?:         string
		loadBalancerArn: string
		port:            int & >=1 & <=65535
		protocol:        "HTTP" | "HTTPS" | "TCP" | "UDP" | "TLS" | "TCP_UDP"
		sslPolicy?:      string
		certificateArn?: string
		alpnPolicy?:     string
		defaultActions: [...#ListenerAction] & [_, ...]
		tags: [string]: string
	}

	outputs?: {
		listenerArn: string
		port:        int
		protocol:    string
	}
}

#ListenerAction: {
	type:            "forward" | "redirect" | "fixed-response"
	targetGroupArn?: string
	redirectConfig?: {
		protocol:   string
		host:       string
		port:       string
		path:       string
		query:      string
		statusCode: "HTTP_301" | "HTTP_302"
	}
	fixedResponseConfig?: {
		statusCode:  string
		contentType: string
		messageBody: string
	}
}

View this schema on GitHub →