SELECT * FROM iasql_install('<modules>');
INSERT INTO target_group (target_group_name, target_type, protocol, port, vpc, health_check_path)
VALUES ('<tgName>', '<tgType>', '<protocol>',<port>, null, '/health');
SELECT *
FROM target_group
WHERE target_group_name = '<tgName>';
UPDATE target_group
SET health_check_path = '/fake-health'
WHERE target_group_name = '<tgName>';
UPDATE target_group
SET port = 5677
WHERE target_group_name = '<tgName>';
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>');
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;
UPDATE load_balancer SET attributes='<loadBalancerAttributes>' WHERE load_balancer_name='<lbName>';
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>');
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>'));
UPDATE listener
SET port =<lbName>WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '');
SELECT * FROM certificate_import('<cert>', '<key>', '<region>', '{}');
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>'));
SELECT *
FROM listener
WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>');
DELETE
FROM listener
WHERE load_balancer_id = (SELECT id FROM load_balancer WHERE load_balancer_name = '<lbName>');
DELETE
FROM load_balancer
WHERE load_balancer_name = '<lbName>';
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;
DELETE
FROM target_group
WHERE target_group_name = '<tgName>';
DELETE
FROM certificate
WHERE domain_name = '<domainName>';
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');
SELECT target_group_arn
FROM target_group
WHERE target_group_name = '<tgName>';
INSERT INTO security_group (description, group_name, region)
VALUES ('Security Group Multi-region Test 1', '<sg1>', 'us-east-1');
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;
SELECT load_balancer_arn
FROM load_balancer
WHERE load_balancer_name = '<lbName>';
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>'));
SELECT listener_arn
FROM listener;
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;