Accelerator

class aws_cdk.aws_globalaccelerator.Accelerator(scope, id, *, accelerator_name=None, enabled=None, ip_addresses=None, ip_address_type=None)

Bases: Resource

The Accelerator construct.

ExampleMetadata:

infused

Example:

# Create an Accelerator
accelerator = globalaccelerator.Accelerator(self, "Accelerator")

# Create a Listener
listener = accelerator.add_listener("Listener",
    port_ranges=[globalaccelerator.PortRange(from_port=80), globalaccelerator.PortRange(from_port=443)
    ]
)

# Import the Load Balancers
nlb1 = elbv2.NetworkLoadBalancer.from_network_load_balancer_attributes(self, "NLB1",
    load_balancer_arn="arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
)
nlb2 = elbv2.NetworkLoadBalancer.from_network_load_balancer_attributes(self, "NLB2",
    load_balancer_arn="arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1"
)

# Add one EndpointGroup for each Region we are targeting
listener.add_endpoint_group("Group1",
    endpoints=[ga_endpoints.NetworkLoadBalancerEndpoint(nlb1)]
)
listener.add_endpoint_group("Group2",
    # 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=[ga_endpoints.NetworkLoadBalancerEndpoint(nlb2)]
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • accelerator_name (Optional[str]) – The name of the accelerator. Default: - resource ID

  • enabled (Optional[bool]) – Indicates whether the accelerator is enabled. Default: true

  • ip_addresses (Optional[Sequence[str]]) – IP addresses associated with the accelerator. Optionally, if you’ve added your own IP address pool to Global Accelerator (BYOIP), you can choose IP addresses from your own pool to use for the accelerator’s static IP addresses when you create an accelerator. You can specify one or two addresses, separated by a comma. Do not include the /32 suffix. Only one IP address from each of your IP address ranges can be used for each accelerator. If you specify only one IP address from your IP address range, Global Accelerator assigns a second static IP address for the accelerator from the AWS IP address pool. Note that you can’t update IP addresses for an existing accelerator. To change them, you must create a new accelerator with the new addresses. Default: - undefined. IP addresses will be from Amazon’s pool of IP addresses.

  • ip_address_type (Optional[IpAddressType]) – The IP address type that an accelerator supports. For a standard accelerator, the value can be IPV4 or DUAL_STACK. Default: - “IPV4”

Methods

add_listener(id, *, port_ranges, client_affinity=None, listener_name=None, protocol=None)

Add a listener to the accelerator.

Parameters:
  • id (str) –

  • port_ranges (Sequence[Union[PortRange, Dict[str, Any]]]) – The list of port ranges for the connections from clients to the accelerator.

  • client_affinity (Optional[ClientAffinity]) – Client affinity to direct all requests from a user to the same endpoint. If you have stateful applications, client affinity lets you direct all requests from a user to the same endpoint. By default, each connection from each client is routed to seperate endpoints. Set client affinity to SOURCE_IP to route all connections from a single client to the same endpoint. Default: ClientAffinity.NONE

  • listener_name (Optional[str]) – Name of the listener. Default: - logical ID of the resource

  • protocol (Optional[ConnectionProtocol]) – The protocol for the connections from clients to the accelerator. Default: ConnectionProtocol.TCP

Return type:

Listener

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

accelerator_arn

The ARN of the accelerator.

dns_name

The Domain Name System (DNS) name that Global Accelerator creates that points to your accelerator’s static IP addresses.

dual_stack_dns_name

two IPv4 addresses and two IPv6 addresses.

Type:

The DNS name that points to the dual-stack accelerator’s four static IP addresses

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

ipv4_addresses

The array of IPv4 addresses in the IP address set.

ipv6_addresses

The array of IPv6 addresses in the IP address set.

node

The tree node.

stack

The stack in which this resource is defined.

Static Methods

classmethod from_accelerator_attributes(scope, id, *, accelerator_arn, dns_name, dual_stack_dns_name=None, ipv4_addresses=None, ipv6_addresses=None)

import from attributes.

Parameters:
  • scope (Construct) –

  • id (str) –

  • accelerator_arn (str) – The ARN of the accelerator.

  • dns_name (str) – The DNS name of the accelerator.

  • dual_stack_dns_name (Optional[str]) – The DNS name that points to the dual-stack accelerator’s four static IP addresses: two IPv4 addresses and two IPv6 addresses. Default: - undefined

  • ipv4_addresses (Optional[Sequence[str]]) – The array of IPv4 addresses in the IP address set. Default: - undefined

  • ipv6_addresses (Optional[Sequence[str]]) – The array of IPv6 addresses in the IP address set. Default: - undefined

Return type:

IAccelerator

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool