aws_elb
- Components
- Code examples
Tables​
    listener
    load_balancer
    target_group
Enums​
    action_type
    ip_address_type
    load_balancer_scheme
    load_balancer_state
    load_balancer_type
    protocol
    protocol_version
    target_group_ip_address_type
    target_type
Manage ELB
--- installs the elb module
SELECT * FROM iasql_install('<modules>');
--- adds a new targetGroup
INSERT INTO target_group (target_group_name, target_type, protocol, port, vpc, health_check_path)
VALUES ('<tgName>', '<tgType>', '<protocol>',<port>, null, '/health');
--- check target_group insertion
SELECT *
FROM target_group
WHERE target_group_name = '<tgName>';
--- tries to update a target group field
UPDATE target_group
SET health_check_path = '/fake-health'
WHERE target_group_name = '<tgName>';
--- tries to update a target group field (replace)
UPDATE target_group
SET port = 5677
WHERE target_group_name = '<tgName>';
--- adds new security groups
INSERT INTO security_group (description, group_name)
VALUES ('Security Group Test 1', '<sg1>');
INSERT INTO security_group (description, group_name)
VALUES ('Security Group Test 2', '<sg2>');
--- adds a new load balancer
BEGIN;
INSERT INTO load_balancer (load_balancer_name, scheme, vpc, load_balancer_type, ip_address_type)
VALUES ('<lbName>', '<lbScheme>', null, '<lbType>', '<lbIPAddressType>');
INSERT INTO load_balancer_security_groups(load_balancer_id, security_group_id)
SELECT (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>'),
(SELECT id FROM security_group WHERE group_name = '<sg1>');
COMMIT;
--- tries to update a load balancer attribute (update)
UPDATE load_balancer SET attributes='<loadBalancerAttributes>' WHERE load_balancer_name='<lbName>';
--- tries to update a load balancer security group (replace)
UPDATE load_balancer_security_groups
SET security_group_id = (SELECT id FROM security_group WHERE group_name = '<sg2>')
WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>');
--- adds a new listener
INSERT INTO listener (load_balancer_id, port, protocol, target_group_id)
VALUES ((SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>'),<port>,
'<protocol>',
(SELECT id FROM target_group WHERE target_group_name = '<tgName>'));
--- tries to update a listener field
UPDATE listener
SET port =<lbName>WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '');
--- adds a new certificate to import
SELECT * FROM certificate_import('<cert>', '<key>', '<region>', '{}');
--- adds a new HTTPS listener
INSERT INTO listener (load_balancer_id, port, protocol, target_group_id, certificate_id)
VALUES ((SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>'),<portHTTPS>,
'<protocolHTTPS>',
(SELECT id FROM target_group WHERE target_group_name = '<tgName>'),
(SELECT id FROM certificate WHERE domain_name = '<domainName>'));
--- check https listener insertion
SELECT *
FROM listener
WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>');
--- deletes the listener
DELETE
FROM listener
WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>');
--- deletes the load balancer
DELETE
FROM load_balancer
WHERE load_balancer_name = '<lbName>';
--- deletes the security groups
BEGIN;
DELETE
FROM security_group_rule
WHERE security_group_id IN (
SELECT id
FROM security_group
WHERE group_name IN ('<sg1>', '<sg2>')
);
DELETE
FROM security_group
WHERE group_name IN ('<sg1>', '<sg2>');
COMMIT;
--- deletes the target group
DELETE
FROM target_group
WHERE target_group_name = '<tgName>';
--- deletes the certificate
DELETE
FROM certificate
WHERE domain_name = '<domainName>';
--- creates a target group in non-default region
INSERT INTO target_group (target_group_name, target_type, protocol, port, vpc, health_check_path, region)
VALUES ('<tgName>', '<tgType>', '<protocol>',<port>, null, '/health', 'us-east-1');
--- verifies the target group is created
SELECT target_group_arn
FROM target_group
WHERE target_group_name = '<tgName>';
--- creates a security group in non-default region
INSERT INTO security_group (description, group_name, region)
VALUES ('Security Group Multi-region Test 1', '<sg1>', 'us-east-1');
--- creates a load balancer in non-default region
BEGIN;
INSERT INTO load_balancer (load_balancer_name, scheme, vpc, load_balancer_type, ip_address_type, region)
VALUES ('<lbName>', '<lbScheme>', null, '<lbType>', '<lbIPAddressType>', 'us-east-1');
INSERT INTO load_balancer_security_groups(load_balancer_id, security_group_id)
SELECT (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>'),
(SELECT id FROM security_group WHERE group_name = '<sg1>');
COMMIT;
--- verifies that load balancer in non-default region is created
SELECT load_balancer_arn
FROM load_balancer
WHERE load_balancer_name = '<lbName>';
--- adds a listener to the load balancer in non-default region
INSERT INTO listener (load_balancer_id, port, protocol, target_group_id)
VALUES ((SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>'),<port>,
'<protocol>',
(SELECT id FROM target_group WHERE target_group_name = '<tgName>'));
--- verifies the listener in non-default region is created
SELECT listener_arn
FROM listener;
--- deletes multi-region resources
BEGIN;
DELETE
FROM listener
WHERE target_group_id = (SELECT id FROM target_group WHERE target_group_name = '<tgName>');
DELETE
FROM target_group
WHERE target_group_name = '<tgName>';
DELETE
FROM security_group
WHERE group_name = '<sg1>';
DELETE
FROM load_balancer
WHERE load_balancer_name = '<lbName>';
COMMIT;