Skip to main content

load_balancers

Creates, updates, deletes, gets or lists a load_balancers resource.

Overview

Nameload_balancers
TypeResource
Idaws.lightsail.load_balancers

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe name of the load balancer (my-load-balancer). (pattern: <code>\w[\w-]*\w</code>)
arnstringThe Amazon Resource Name (ARN) of the load balancer. (pattern: <code>.\S.</code>)
configuration_optionsobjectA string to string map of the configuration options for your load balancer. Valid values are listed below.
created_atstring (date-time)The date when your load balancer was created.
dns_namestringThe DNS name of your Lightsail load balancer. (pattern: <code>.\S.</code>)
health_check_pathstringThe path you specified to perform your health checks. If no path is specified, the load balancer tries to make a request to the default (root) page. (pattern: <code>.\S.</code>)
https_redirection_enabledbooleanA Boolean value that indicates whether HTTPS redirection is enabled for the load balancer.
instance_health_summaryarrayAn array of InstanceHealthSummary objects describing the health of the load balancer.
instance_portintegerThe port where the load balancer will direct traffic to your Lightsail instances. For HTTP traffic, it's port 80. For HTTPS traffic, it's port 443.
ip_address_typestringThe IP address type of the load balancer. The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack for IPv4 and IPv6. (dualstack, ipv4, ipv6)
locationobjectThe AWS Region where your load balancer was created (us-east-2a). Lightsail automatically creates your load balancer across Availability Zones.
protocolstringThe protocol you have enabled for your load balancer. Valid values are below. You can't just have HTTP_HTTPS, but you can have just HTTP. (HTTP_HTTPS, HTTP)
public_portsarrayAn array of public port settings for your load balancer. For HTTP, use port 80. For HTTPS, use port 443.
resource_typestringThe resource type (LoadBalancer. (ContainerService, Instance, StaticIp, KeyPair, InstanceSnapshot, Domain, PeeredVpc, LoadBalancer, LoadBalancerTlsCertificate, Disk, DiskSnapshot, RelationalDatabase, RelationalDatabaseSnapshot, ExportSnapshotRecord, CloudFormationStackRecord, Alarm, ContactMethod, Distribution, Certificate, Bucket)
statestringThe status of your load balancer. Valid values are below. (active, provisioning, active_impaired, failed, unknown)
support_codestringThe support code. Include this code in your email to support when you have questions about your Lightsail load balancer. This code enables our support team to look up your Lightsail information more easily.
tagsarrayThe tag keys and optional values for the resource. For more information about tags in Lightsail, see the Amazon Lightsail Developer Guide.
tls_certificate_summariesarrayAn array of LoadBalancerTlsCertificateSummary objects that provide additional information about the SSL/TLS certificates. For example, if true, the certificate is attached to the load balancer.
tls_policy_namestringThe name of the TLS security policy for the load balancer. (pattern: <code>\w[\w-]*\w</code>)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_load_balancerselectregionReturns information about the specified Lightsail load balancer.
get_load_balancersselectregionReturns information about all load balancers in an account.
create_load_balancerinsertregion, loadBalancerName, instancePortCreates a Lightsail load balancer. To learn more about deciding whether to load balance your application, see Configure your Lightsail instances for load balancing. You can create up to 10 load balancers per AWS Region in your account. When you create a load balancer, you can specify a unique name and port settings. To change additional load balancer settings, use the UpdateLoadBalancerAttribute operation. The create load balancer operation supports tag-based access control via request tags. For more information, see the Amazon Lightsail Developer Guide.
update_load_balancer_attributeupdateregion, loadBalancerName, attributeName, attributeValueUpdates the specified attribute for a load balancer. You can only update one attribute at a time. The update load balancer attribute operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Amazon Lightsail Developer Guide.
attach_instances_to_load_balancerupdateregion, loadBalancerName, instanceNamesAttaches one or more Lightsail instances to a load balancer. After some time, the instances are attached to the load balancer and the health check status is available. The attach instances to load balancer operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Lightsail Developer Guide.
delete_load_balancerdeleteregionDeletes a Lightsail load balancer and all its associated SSL/TLS certificates. Once the load balancer is deleted, you will need to create a new load balancer, create a new certificate, and verify domain ownership again. The delete load balancer operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Amazon Lightsail Developer Guide.
detach_instances_from_load_balancerexecregion, loadBalancerName, instanceNamesDetaches the specified instances from a Lightsail load balancer. This operation waits until the instances are no longer needed before they are detached from the load balancer. The detach instances from load balancer operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Amazon Lightsail Developer Guide.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Returns information about the specified Lightsail load balancer.

SELECT
name,
arn,
configuration_options,
created_at,
dns_name,
health_check_path,
https_redirection_enabled,
instance_health_summary,
instance_port,
ip_address_type,
location,
protocol,
public_ports,
resource_type,
state,
support_code,
tags,
tls_certificate_summaries,
tls_policy_name
FROM aws.lightsail.load_balancers
WHERE region = '{{ region }}' -- required
;

INSERT examples

Creates a Lightsail load balancer. To learn more about deciding whether to load balance your application, see Configure your Lightsail instances for load balancing. You can create up to 10 load balancers per AWS Region in your account. When you create a load balancer, you can specify a unique name and port settings. To change additional load balancer settings, use the UpdateLoadBalancerAttribute operation. The create load balancer operation supports tag-based access control via request tags. For more information, see the Amazon Lightsail Developer Guide.

INSERT INTO aws.lightsail.load_balancers (
loadBalancerName,
instancePort,
healthCheckPath,
certificateName,
certificateDomainName,
certificateAlternativeNames,
tags,
ipAddressType,
tlsPolicyName,
region
)
SELECT
'{{ loadBalancerName }}' /* required */,
{{ instancePort }} /* required */,
'{{ healthCheckPath }}',
'{{ certificateName }}',
'{{ certificateDomainName }}',
'{{ certificateAlternativeNames }}',
'{{ tags }}',
'{{ ipAddressType }}',
'{{ tlsPolicyName }}',
'{{ region }}'
RETURNING
operations
;

UPDATE examples

Updates the specified attribute for a load balancer. You can only update one attribute at a time. The update load balancer attribute operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Amazon Lightsail Developer Guide.

UPDATE aws.lightsail.load_balancers
SET
loadBalancerName = '{{ loadBalancerName }}',
attributeName = '{{ attributeName }}',
attributeValue = '{{ attributeValue }}'
WHERE
region = '{{ region }}' --required
AND loadBalancerName = '{{ loadBalancerName }}' --required
AND attributeName = '{{ attributeName }}' --required
AND attributeValue = '{{ attributeValue }}' --required
RETURNING
operations;

DELETE examples

Deletes a Lightsail load balancer and all its associated SSL/TLS certificates. Once the load balancer is deleted, you will need to create a new load balancer, create a new certificate, and verify domain ownership again. The delete load balancer operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Amazon Lightsail Developer Guide.

DELETE FROM aws.lightsail.load_balancers
WHERE region = '{{ region }}' --required
;

Lifecycle Methods

Detaches the specified instances from a Lightsail load balancer. This operation waits until the instances are no longer needed before they are detached from the load balancer. The detach instances from load balancer operation supports tag-based access control via resource tags applied to the resource identified by load balancer name. For more information, see the Amazon Lightsail Developer Guide.

EXEC aws.lightsail.load_balancers.detach_instances_from_load_balancer
@region='{{ region }}' --required
@@json=
'{
"loadBalancerName": "{{ loadBalancerName }}",
"instanceNames": "{{ instanceNames }}"
}'
;