See: Description
| Interface | Description |
|---|---|
| AcceleratorAttributes |
(experimental) Attributes required to import an existing accelerator to the stack.
|
| AcceleratorProps |
(experimental) Construct properties of the Accelerator.
|
| CfnAcceleratorProps |
Properties for defining a `AWS::GlobalAccelerator::Accelerator`.
|
| CfnEndpointGroup.EndpointConfigurationProperty | |
| CfnEndpointGroup.PortOverrideProperty | |
| CfnEndpointGroupProps |
Properties for defining a `AWS::GlobalAccelerator::EndpointGroup`.
|
| CfnListener.PortRangeProperty | |
| CfnListenerProps |
Properties for defining a `AWS::GlobalAccelerator::Listener`.
|
| EndpointGroupOptions |
(experimental) Basic options for creating a new EndpointGroup.
|
| EndpointGroupProps |
(experimental) Property of the EndpointGroup.
|
| IAccelerator |
(experimental) The interface of the Accelerator.
|
| IAccelerator.Jsii$Default |
Internal default implementation for
IAccelerator. |
| IEndpoint |
(experimental) An endpoint for the endpoint group.
|
| IEndpoint.Jsii$Default |
Internal default implementation for
IEndpoint. |
| IEndpointGroup |
(experimental) The interface of the EndpointGroup.
|
| IEndpointGroup.Jsii$Default |
Internal default implementation for
IEndpointGroup. |
| IListener |
(experimental) Interface of the Listener.
|
| IListener.Jsii$Default |
Internal default implementation for
IListener. |
| ListenerOptions |
(experimental) Construct options for Listener.
|
| ListenerProps |
(experimental) Construct properties for Listener.
|
| PortOverride |
(experimental) Override specific listener ports used to route traffic to endpoints that are part of an endpoint group.
|
| PortRange |
(experimental) The list of port ranges for the connections from clients to the accelerator.
|
| RawEndpointProps |
(experimental) Properties for RawEndpoint.
|
| Enum | Description |
|---|---|
| ClientAffinity |
(experimental) Client affinity gives you control over whether to always route each client to the same specific endpoint.
|
| ConnectionProtocol |
(experimental) The protocol for the connections from clients to the accelerator.
|
| HealthCheckProtocol |
(experimental) The protocol for the connections from clients to the accelerator.
|
---
AWS Global Accelerator (AGA) is a service that improves the availability and performance of your applications with local or global users.
It intercepts your user's network connection at an edge location close to them, and routes it to one of potentially multiple, redundant backends across the more reliable and less congested AWS global network.
AGA can be used to route traffic to Application Load Balancers, Network Load Balancers, EC2 Instances and Elastic IP Addresses.
For more information, see the AWS Global Accelerator Developer Guide.
Here's an example that sets up a Global Accelerator for two Application Load Balancers in two different AWS Regions:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import software.amazon.awscdk.aws_globalaccelerator;
import software.amazon.awscdk.aws_globalaccelerator_endpoints;
import software.amazon.awscdk.aws_elasticloadbalancingv2;
// Create an Accelerator
Accelerator accelerator = new Accelerator(stack, "Accelerator");
// Create a Listener
Listener listener = accelerator.addListener("Listener", new ListenerOptions()
.portRanges(asList(new PortRange().fromPort(80), new PortRange().fromPort(443))));
// Import the Load Balancers
INetworkLoadBalancer nlb1 = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(stack, "NLB1", new NetworkLoadBalancerAttributes()
.loadBalancerArn("arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"));
INetworkLoadBalancer nlb2 = elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(stack, "NLB2", new NetworkLoadBalancerAttributes()
.loadBalancerArn("arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1"));
// Add one EndpointGroup for each Region we are targeting
listener.addEndpointGroup("Group1", new EndpointGroupOptions()
.endpoints(asList(new NetworkLoadBalancerEndpoint(nlb1))));
listener.addEndpointGroup("Group2", new EndpointGroupOptions()
// Imported load balancers automatically calculate their Region from the ARN.
// If you are load balancing to other resources, you must also pass a `region`
// parameter here.
.endpoints(asList(new NetworkLoadBalancerEndpoint(nlb2))));
The Accelerator construct defines a Global Accelerator resource.
An Accelerator includes one or more Listeners that accepts inbound connections on one or more ports.
Each Listener has one or more Endpoint Groups, representing multiple geographically distributed copies of your application. There is one Endpoint Group per Region, and user traffic is routed to the closest Region by default.
An Endpoint Group consists of one or more Endpoints, which is where the user traffic coming in on the Listener is ultimately sent. The Endpoint port used is the same as the traffic came in on at the Listener, unless overridden.
There are 4 types of Endpoints, and they can be found in the
@aws-cdk/aws-globalaccelerator-endpoints package:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Object alb = new ApplicationLoadBalancer(...);
listener.addEndpointGroup("Group", Map.of(
"endpoints", asList(
ApplicationLoadBalancerEndpoint.Builder.create(alb)
.weight(128)
.preserveClientIp(true)
.build())));
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Object nlb = new NetworkLoadBalancer(...);
listener.addEndpointGroup("Group", Map.of(
"endpoints", asList(
NetworkLoadBalancerEndpoint.Builder.create(nlb)
.weight(128)
.build())));
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Object instance = new instance(...);
listener.addEndpointGroup("Group", Map.of(
"endpoints", asList(
InstanceEndpoint.Builder.create(instance)
.weight(128)
.preserveClientIp(true)
.build())));
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Object eip = new CfnEIP(...);
listener.addEndpointGroup("Group", Map.of(
"endpoints", asList(
CfnEipEndpoint.Builder.create(eip)
.weight(128)
.build())));
When using the preserveClientIp feature, AGA creates
Elastic Network Interfaces (ENIs) in your AWS account, that are
associated with a Security Group AGA creates for you. You can use the
security group created by AGA as a source group in other security groups
(such as those for EC2 instances or Elastic Load Balancers), if you want to
restrict incoming traffic to the AGA security group rules.
AGA creates a specific security group called GlobalAccelerator for each VPC
it has an ENI in (this behavior can not be changed). CloudFormation doesn't
support referencing the security group created by AGA, but this construct
library comes with a custom resource that enables you to reference the AGA
security group.
Call endpointGroup.connectionsPeer() to obtain a reference to the Security Group
which you can use in connection rules. You must pass a reference to the VPC in whose
context the security group will be looked up. Example:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
// ...
// Non-open ALB
Object alb = ApplicationLoadBalancer.Builder.create(stack, "ALB").build();
Object endpointGroup = listener.addEndpointGroup("Group", Map.of(
"endpoints", asList(
ApplicationLoadBalancerEndpoint.Builder.create(alb)
.preserveClientIps(true)
.build())));
// Remember that there is only one AGA security group per VPC.
Object agaSg = endpointGroup.connectionsPeer("GlobalAcceleratorSG", vpc);
// Allow connections from the AGA to the ALB
alb.connections.allowFrom(agaSg, Port.tcp(443));
Copyright © 2021. All rights reserved.