Elastic Load Balancing · Networking

TargetGroup

Declare target groups, protocols, ports, and health checks.

Generic driverUniform lifecycle
Scope
Regional
Spec fields
12
Outputs
2
Lookup
Supported

Resource definition

What this resource looks like

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

CUE example
resources: {
  targetGroup: {
  	apiVersion: "praxis.io/alpha"
  	kind:       "TargetGroup"
  	metadata: name: "\(_naming.prefix)-app-tg"
  	spec: {
  		region:     _naming.region
  		port:       8080
  		protocol:   "HTTP"
  		vpcId:      "${resources.vpc.outputs.vpcId}"
  		targetType: "instance"
  		healthCheck: {
  			path:               "/healthz"
  			protocol:           "HTTP"
  			port:               "8080"
  			healthyThreshold:   3
  			unhealthyThreshold: 3
  			interval:           30
  			timeout:            5
  		}
  		tags: #AppTags
  	}
  }
}

Excerpted from examples/stacks/end-to-end.cue. Open the complete example for its variables and related resources.

Complete examples in the repository

Desired state

Configuration

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

regionRequired

Region.

string
String
accountOptional

Account.

string
String
protocolRequired

Protocol.

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

Port.

int & >=1 & <=65535
Integer
vpcIdRequired

Vpc ID.

string
String
targetTypeOptional

Target Type.

"instance" | "ip" | "lambda" | *"instance"
EnumDefault "instance"
protocolVersionOptional

Protocol Version.

"HTTP1" | "HTTP2" | "gRPC"
Enum
healthCheckOptional

Health Check.

{ protocol: "HTTP" | "HTTPS" | "TCP" | "TLS" | *"HTTP" path?: string port: string | *"traffic-port" healthyThreshold: int & >=2 & <=10 | *5 unhealthyThreshold: int & >=2 & <=10 | *2 interval: int & >=5 & <=300 | *30 timeout: int & >=2 & <=120 | *5 matcher?: string }
Object
deregistrationDelayOptional

Deregistration Delay.

int & >=0 & <=3600 | *300
IntegerDefault 300
stickinessOptional

Stickiness.

{ enabled: bool | *false type: "lb_cookie" | "app_cookie" | "source_ip" | *"lb_cookie" duration: int & >=1 & <=604800 | *86400 }
Object
targetsOptional

Targets.

[...#Target] | *[]
ListDefault []
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>}.

targetGroupArnString
targetGroupNameString

Read without ownership

Data-source lookup

A data block reads an existing TargetGroup 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: "TargetGroup"
  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 TargetGroup. The example starts in observed mode so Praxis reports drift without correcting it.

CLI
praxis import TargetGroup \
  --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/target_group.cue
package elb

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

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

	spec: {
		region:           string
		account?:         string
		protocol:         "HTTP" | "HTTPS" | "TCP" | "UDP" | "TLS" | "TCP_UDP"
		port:             int & >=1 & <=65535
		vpcId:            string
		targetType:       "instance" | "ip" | "lambda" | *"instance"
		protocolVersion?: "HTTP1" | "HTTP2" | "gRPC"
		healthCheck?: {
			protocol:           "HTTP" | "HTTPS" | "TCP" | "TLS" | *"HTTP"
			path?:              string
			port:               string | *"traffic-port"
			healthyThreshold:   int & >=2 & <=10 | *5
			unhealthyThreshold: int & >=2 & <=10 | *2
			interval:           int & >=5 & <=300 | *30
			timeout:            int & >=2 & <=120 | *5
			matcher?:           string
		}
		deregistrationDelay: int & >=0 & <=3600 | *300
		stickiness?: {
			enabled:  bool | *false
			type:     "lb_cookie" | "app_cookie" | "source_ip" | *"lb_cookie"
			duration: int & >=1 & <=604800 | *86400
		}
		targets: [...#Target] | *[]
		tags: [string]: string
	}

	outputs?: {
		targetGroupArn:  string
		targetGroupName: string
	}
}

#Target: {
	id:                string
	port?:             int & >=1 & <=65535
	availabilityZone?: string
}

View this schema on GitHub →