@grucloud/module-aws-load-balancer
Version:
GruCloud Module to create load balancer, target group and rule
81 lines (79 loc) • 1.77 kB
JavaScript
const pkg = require("./package.json");
module.exports = ({ stage }) => ({
ELBv2: {
loadBalancer: { name: `load-balancer` },
targetGroups: {
web: {
name: `target-group-web`,
properties: {
Port: 30010,
},
},
rest: {
name: `target-group-rest`,
properties: {
Port: 30020,
HealthCheckPath: "/api/v1/version",
},
},
},
listeners: {
http: { name: `listener-http` },
https: { name: `listener-https` },
},
rules: {
http2https: {
name: `rule-http-redirect-https`,
properties: {
Actions: [
{
Type: "redirect",
Order: 1,
RedirectConfig: {
Protocol: "HTTPS",
Port: "443",
Host: "#{host}",
Path: "/#{path}",
Query: "#{query}",
StatusCode: "HTTP_301",
},
},
],
Conditions: [
{
Field: "path-pattern",
Values: ["/*"],
},
],
Priority: "1",
},
},
https: {
rest: {
name: `rule-rest-https`,
properties: {
Conditions: [
{
Field: "path-pattern",
Values: ["/api/*"],
},
],
Priority: "10",
},
},
web: {
name: `rule-web-https`,
properties: {
Conditions: [
{
Field: "path-pattern",
Values: ["/*"],
},
],
Priority: "11",
},
},
},
},
},
});