awselasticloadbalancingv2targets

package
v2.159.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

Targets for AWS Elastic Load Balancing V2

This package contains targets for ELBv2. See the README of the aws-cdk-lib/aws-elasticloadbalancingv2 library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAlbArnTarget_Override

func NewAlbArnTarget_Override(a AlbArnTarget, albArn *string, port *float64)

Create a new alb target.

Note that the ALB must have a listener on the provided target port.

func NewAlbListenerTarget_Override added in v2.154.0

func NewAlbListenerTarget_Override(a AlbListenerTarget, albListener awselasticloadbalancingv2.ApplicationListener)

Create a new ALB target.

The associated target group will automatically have a dependency added against the ALB's listener.

func NewAlbTarget_Override deprecated

func NewAlbTarget_Override(a AlbTarget, alb awselasticloadbalancingv2.IApplicationLoadBalancer, port *float64)

Deprecated: Use `AlbListenerTarget` instead or `AlbArnTarget` for an imported load balancer. This target does not automatically add a dependency between the ALB listener and resulting NLB target group, without which may cause stack deployments to fail if the NLB target group is provisioned before the listener has been fully created.

func NewInstanceIdTarget_Override

func NewInstanceIdTarget_Override(i InstanceIdTarget, instanceId *string, port *float64)

Create a new Instance target.

func NewInstanceTarget_Override

func NewInstanceTarget_Override(i InstanceTarget, instance awsec2.Instance, port *float64)

Create a new Instance target.

func NewIpTarget_Override

func NewIpTarget_Override(i IpTarget, ipAddress *string, port *float64, availabilityZone *string)

Create a new IPAddress target.

The availabilityZone parameter determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.

This parameter is not supported if the target type of the target group is instance. If the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required.

With an Application Load Balancer, if the IP address is outside the VPC for the target group, the only supported value is all.

Default is automatic.

func NewLambdaTarget_Override

func NewLambdaTarget_Override(l LambdaTarget, fn awslambda.IFunction)

Create a new Lambda target.

Types

type AlbArnTarget

type AlbArnTarget interface {
	awselasticloadbalancingv2.INetworkLoadBalancerTarget
	// Register this alb target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

A single Application Load Balancer as the target for load balancing.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

albArnTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewAlbArnTarget(jsii.String("albArn"), jsii.Number(123))

func NewAlbArnTarget

func NewAlbArnTarget(albArn *string, port *float64) AlbArnTarget

Create a new alb target.

Note that the ALB must have a listener on the provided target port.

type AlbListenerTarget added in v2.154.0

type AlbListenerTarget interface {
	AlbArnTarget
	// Register this ALB target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	//
	// This adds dependency on albListener because creation of ALB listener and NLB can vary during runtime.
	// More Details on - https://github.com/aws/aws-cdk/issues/17208
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

A single Application Load Balancer's listener as the target for load balancing.

Example:

import targets "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import patterns "github.com/aws/aws-cdk-go/awscdk"

var vpc vpc

task := ecs.NewFargateTaskDefinition(this, jsii.String("Task"), &FargateTaskDefinitionProps{
	Cpu: jsii.Number(256),
	MemoryLimitMiB: jsii.Number(512),
})
task.AddContainer(jsii.String("nginx"), &ContainerDefinitionOptions{
	Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/nginx/nginx:latest")),
	PortMappings: []portMapping{
		&portMapping{
			ContainerPort: jsii.Number(80),
		},
	},
})

svc := patterns.NewApplicationLoadBalancedFargateService(this, jsii.String("Service"), &ApplicationLoadBalancedFargateServiceProps{
	Vpc: Vpc,
	TaskDefinition: task,
	PublicLoadBalancer: jsii.Boolean(false),
})

nlb := elbv2.NewNetworkLoadBalancer(this, jsii.String("Nlb"), &NetworkLoadBalancerProps{
	Vpc: Vpc,
	CrossZoneEnabled: jsii.Boolean(true),
	InternetFacing: jsii.Boolean(true),
})

listener := nlb.AddListener(jsii.String("listener"), &BaseNetworkListenerProps{
	Port: jsii.Number(80),
})

listener.AddTargets(jsii.String("Targets"), &AddNetworkTargetsProps{
	Targets: []iNetworkLoadBalancerTarget{
		targets.NewAlbListenerTarget(svc.Listener),
	},
	Port: jsii.Number(80),
})

awscdk.NewCfnOutput(this, jsii.String("NlbEndpoint"), &CfnOutputProps{
	Value: fmt.Sprintf("http://%v", nlb.LoadBalancerDnsName),
})

func NewAlbListenerTarget added in v2.154.0

func NewAlbListenerTarget(albListener awselasticloadbalancingv2.ApplicationListener) AlbListenerTarget

Create a new ALB target.

The associated target group will automatically have a dependency added against the ALB's listener.

type AlbTarget deprecated

type AlbTarget interface {
	AlbArnTarget
	// Register this alb target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	// Deprecated: Use `AlbListenerTarget` instead or
	// `AlbArnTarget` for an imported load balancer. This target does not automatically
	// add a dependency between the ALB listener and resulting NLB target group,
	// without which may cause stack deployments to fail if the NLB target group is provisioned
	// before the listener has been fully created.
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

A single Application Load Balancer as the target for load balancing.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var applicationLoadBalancer applicationLoadBalancer

albTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewAlbTarget(applicationLoadBalancer, jsii.Number(123))

Deprecated: Use `AlbListenerTarget` instead or `AlbArnTarget` for an imported load balancer. This target does not automatically add a dependency between the ALB listener and resulting NLB target group, without which may cause stack deployments to fail if the NLB target group is provisioned before the listener has been fully created.

func NewAlbTarget deprecated

Deprecated: Use `AlbListenerTarget` instead or `AlbArnTarget` for an imported load balancer. This target does not automatically add a dependency between the ALB listener and resulting NLB target group, without which may cause stack deployments to fail if the NLB target group is provisioned before the listener has been fully created.

type InstanceIdTarget

type InstanceIdTarget interface {
	awselasticloadbalancingv2.IApplicationLoadBalancerTarget
	awselasticloadbalancingv2.INetworkLoadBalancerTarget
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToApplicationTargetGroup(targetGroup awselasticloadbalancingv2.IApplicationTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

An EC2 instance that is the target for load balancing.

If you register a target of this type, you are responsible for making sure the load balancer's security group can connect to the instance.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

instanceIdTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewInstanceIdTarget(jsii.String("instanceId"), jsii.Number(123))

func NewInstanceIdTarget

func NewInstanceIdTarget(instanceId *string, port *float64) InstanceIdTarget

Create a new Instance target.

type InstanceTarget

type InstanceTarget interface {
	InstanceIdTarget
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToApplicationTargetGroup(targetGroup awselasticloadbalancingv2.IApplicationTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var instance instance

instanceTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewInstanceTarget(instance, jsii.Number(123))

func NewInstanceTarget

func NewInstanceTarget(instance awsec2.Instance, port *float64) InstanceTarget

Create a new Instance target.

type IpTarget

type IpTarget interface {
	awselasticloadbalancingv2.IApplicationLoadBalancerTarget
	awselasticloadbalancingv2.INetworkLoadBalancerTarget
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToApplicationTargetGroup(targetGroup awselasticloadbalancingv2.IApplicationTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

An IP address that is a target for load balancing.

Specify IP addresses from the subnets of the virtual private cloud (VPC) for the target group, the RFC 1918 range (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16), and the RFC 6598 range (100.64.0.0/10). You can't specify publicly routable IP addresses.

If you register a target of this type, you are responsible for making sure the load balancer's security group can send packets to the IP address.

Example:

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

ipTarget := awscdk.Aws_elasticloadbalancingv2_targets.NewIpTarget(jsii.String("ipAddress"), jsii.Number(123), jsii.String("availabilityZone"))

func NewIpTarget

func NewIpTarget(ipAddress *string, port *float64, availabilityZone *string) IpTarget

Create a new IPAddress target.

The availabilityZone parameter determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.

This parameter is not supported if the target type of the target group is instance. If the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required.

With an Application Load Balancer, if the IP address is outside the VPC for the target group, the only supported value is all.

Default is automatic.

type LambdaTarget

type LambdaTarget interface {
	awselasticloadbalancingv2.IApplicationLoadBalancerTarget
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToApplicationTargetGroup(targetGroup awselasticloadbalancingv2.IApplicationTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
	// Register this instance target with a load balancer.
	//
	// Don't call this, it is called automatically when you add the target to a
	// load balancer.
	AttachToNetworkTargetGroup(targetGroup awselasticloadbalancingv2.INetworkTargetGroup) *awselasticloadbalancingv2.LoadBalancerTargetProps
}

Example:

import lambda "github.com/aws/aws-cdk-go/awscdk"
import targets "github.com/aws/aws-cdk-go/awscdk"

var lambdaFunction function
var lb applicationLoadBalancer

listener := lb.AddListener(jsii.String("Listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(80),
})
listener.AddTargets(jsii.String("Targets"), &AddApplicationTargetsProps{
	Targets: []iApplicationLoadBalancerTarget{
		targets.NewLambdaTarget(lambdaFunction),
	},

	// For Lambda Targets, you need to explicitly enable health checks if you
	// want them.
	HealthCheck: &HealthCheck{
		Enabled: jsii.Boolean(true),
	},
})

func NewLambdaTarget

func NewLambdaTarget(fn awslambda.IFunction) LambdaTarget

Create a new Lambda target.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL