SELECT * FROM iasql_install('<modules>');
INSERT INTO iam_role (role_name, assume_role_policy_document, attached_policies_arns)
VALUES ('<roleName>', '<codedeployRolePolicy>', array['<codedeployPolicyArn>', '<deployEC2PolicyArn>']);
INSERT INTO iam_role (role_name, assume_role_policy_document, attached_policies_arns)
VALUES ('<lambdaRoleName>', '<codedeployRolePolicy>', array['<codedeployPolicyArn>', '<deployLambdaPolicyArn>']);
INSERT INTO iam_role (role_name, assume_role_policy_document, attached_policies_arns)
VALUES ('<ec2RoleName>', '<ec2RolePolicy>', array['<deployEC2PolicyArn>', '<ssmPolicyArn>']);
INSERT INTO security_group (description, group_name)
VALUES ('CodedeploySecurity Group', '<sgGroupName>');
INSERT INTO security_group_rule (is_egress, ip_protocol, from_port, to_port, cidr_ipv4, description, security_group_id)
SELECT false, 'tcp', 22, 22, '0.0.0.0/0', '<prefix>codedeploy_rule_ssh', id
FROM security_group
WHERE group_name = '<sgGroupName>';
INSERT INTO security_group_rule (is_egress, ip_protocol, from_port, to_port, cidr_ipv4, description, security_group_id)
SELECT false, 'tcp', 80, 80, '0.0.0.0/0', '<prefix>codedeploy_rule_http', id
FROM security_group
WHERE group_name = '<sgGroupName>';
INSERT INTO security_group_rule (is_egress, ip_protocol, from_port, to_port, cidr_ipv4, description, security_group_id)
SELECT true, 'tcp', 1, 65335, '0.0.0.0/0', '<prefix>codedeploy_rule_egress', id
FROM security_group
WHERE group_name = '<sgGroupName>';
INSERT INTO codedeploy_application (name, compute_platform)
VALUES ('<applicationName>', 'Server');
SELECT * FROM codedeploy_application WHERE name='<applicationName>';
DELETE FROM codedeploy_application
WHERE name = '<applicationName>';
INSERT INTO codedeploy_application (name, compute_platform)
VALUES ('<applicationNameForDeployment>', 'Server');
INSERT INTO codedeploy_deployment_group (application_id, name, role_name)
VALUES ((SELECT id FROM codedeploy_application WHERE name = '<applicationNameForDeployment>'), '<deploymentGroupName>', '<roleName>');
SELECT * FROM codedeploy_deployment_group WHERE name='<deploymentGroupName>';