-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathelb.js
82 lines (82 loc) · 2.77 KB
/
elb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _ = require("lodash");
var ELB = (function () {
function ELB(cluster) {
this.PORTS = {
'HTTP': 80,
'HTTPS': 443,
};
this.cluster = cluster;
}
Object.defineProperty(ELB.prototype, "name", {
get: function () {
return 'ELB';
},
enumerable: true,
configurable: true
});
ELB.prototype.generate = function () {
var _this = this;
var definition = {
'ClsELB': {
'Type': 'AWS::ElasticLoadBalancingV2::LoadBalancer',
'Properties': {
'Scheme': 'internet-facing',
'LoadBalancerAttributes': [
{
'Key': 'idle_timeout.timeout_seconds',
'Value': 30
}
],
'Subnets': this.cluster.subnets,
'SecurityGroups': [this.cluster.securityGroup]
}
}
};
var listeners = _.map(this.cluster.protocol, function (protocol) {
return _this.generateListener(protocol);
});
return _.assign.apply(_, [definition].concat(listeners));
};
ELB.prototype.generateListener = function (protocol) {
var definition = (_a = {},
_a["Cls" + protocol + "Listener"] = {
'Type': 'AWS::ElasticLoadBalancingV2::Listener',
"DependsOn": 'ClsELB',
'Properties': {
'Certificates': [],
'DefaultActions': [
{
'Type': 'forward',
'TargetGroupArn': {
'Ref': "Cls" + protocol + "TargetGroup"
}
}
],
'LoadBalancerArn': {
'Ref': 'ClsELB'
},
'Port': this.PORTS[protocol],
'Protocol': protocol
}
},
_a["Cls" + protocol + "TargetGroup"] = {
'Type': 'AWS::ElasticLoadBalancingV2::TargetGroup',
'DependsOn': 'ClsELB',
'Properties': {
'Port': this.PORTS[protocol],
'Protocol': protocol,
'VpcId': this.cluster.vpcId
}
},
_a);
if (protocol == 'HTTPS') {
definition["Cls" + protocol + "Listener"].Properties.Certificates = [{ 'CertificateArn': this.cluster.certificate }];
}
return definition;
var _a;
};
return ELB;
}());
exports.ELB = ELB;