@spinnaker/amazon 0.11.1 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/domain/IAmazonLaunchTemplate.d.ts +1 -1
  3. package/dist/domain/IAmazonServerGroup.d.ts +10 -0
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/instance/awsInstanceType.service.d.ts +10 -2
  7. package/dist/instance/awsInstanceTypes.d.ts +10 -0
  8. package/dist/instance/details/CostFactor.d.ts +6 -0
  9. package/dist/reactShims/aws.react.injector.d.ts +2 -1
  10. package/dist/search/searchResultFormatter.d.ts +2 -2
  11. package/dist/serverGroup/configure/serverGroupCommandBuilder.service.d.ts +17 -2
  12. package/dist/serverGroup/configure/serverGroupConfiguration.service.d.ts +39 -0
  13. package/dist/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.d.ts +3 -4
  14. package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.d.ts +9 -0
  15. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.d.ts +13 -0
  16. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.d.ts +9 -0
  17. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.d.ts +11 -0
  18. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.d.ts +14 -0
  19. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.d.ts +12 -0
  20. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.d.ts +15 -0
  21. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.d.ts +8 -0
  22. package/dist/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.d.ts +8 -0
  23. package/dist/serverGroup/configure/wizard/pages/ServerGroupInstanceType.d.ts +9 -6
  24. package/dist/serverGroup/serverGroup.transformer.d.ts +2 -1
  25. package/package.json +5 -5
  26. package/src/domain/IAmazonLaunchTemplate.ts +1 -1
  27. package/src/domain/IAmazonServerGroup.ts +11 -0
  28. package/src/function/details/FunctionActions.spec.tsx +10 -9
  29. package/src/help/amazon.help.ts +9 -6
  30. package/src/image/image.reader.spec.ts +75 -0
  31. package/src/instance/awsInstanceType.service.spec.js +37 -71
  32. package/src/instance/awsInstanceType.service.ts +191 -0
  33. package/src/instance/awsInstanceTypes.ts +311 -0
  34. package/src/instance/details/CostFactor.tsx +29 -0
  35. package/src/instance/details/InstanceInformation.spec.tsx +2 -1
  36. package/src/instance/details/instance.details.controller.js +471 -473
  37. package/src/loadBalancer/details/loadBalancerDetails.controller.spec.ts +5 -3
  38. package/src/reactShims/aws.react.injector.ts +2 -1
  39. package/src/search/{searchResultFormatter.js → searchResultFormatter.ts} +5 -4
  40. package/src/serverGroup/configure/AmazonImageSelectInput.spec.tsx +10 -7
  41. package/src/serverGroup/configure/serverGroupCommandBuilder.aws.service.spec.js +302 -1
  42. package/src/serverGroup/configure/{serverGroupCommandBuilder.service.js → serverGroupCommandBuilder.service.ts} +182 -73
  43. package/src/serverGroup/configure/serverGroupCommandBuilder.spec.js +25 -8
  44. package/src/serverGroup/configure/serverGroupConfiguration.service.spec.ts +6 -13
  45. package/src/serverGroup/configure/serverGroupConfiguration.service.ts +53 -0
  46. package/src/serverGroup/configure/wizard/AmazonCloneServerGroupModal.tsx +1 -1
  47. package/src/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.tsx +31 -31
  48. package/src/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.tsx +133 -0
  49. package/src/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.tsx +99 -0
  50. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.tsx +36 -0
  51. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.tsx +144 -0
  52. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.tsx +138 -0
  53. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.tsx +135 -0
  54. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.tsx +137 -0
  55. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.less +5 -0
  56. package/src/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.tsx +108 -0
  57. package/src/serverGroup/configure/wizard/instanceType/advancedMode/advancedMode.less +110 -0
  58. package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.tsx +62 -0
  59. package/src/serverGroup/configure/wizard/pages/ServerGroupInstanceType.tsx +107 -62
  60. package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.tsx +1 -1
  61. package/src/serverGroup/details/scalingPolicy/scalingPolicySummary.component.ts +6 -2
  62. package/src/serverGroup/details/scalingProcesses/AutoScalingProcessService.spec.ts +1 -2
  63. package/src/serverGroup/details/sections/InstancesDistributionDetailsSection.spec.tsx +8 -5
  64. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +8 -5
  65. package/src/serverGroup/serverGroup.transformer.spec.ts +5 -3
  66. package/src/serverGroup/serverGroup.transformer.ts +24 -22
  67. package/src/subnet/SubnetSelectInput.spec.tsx +7 -4
  68. package/src/vpc/{VpcReader.spec.js → VpcReader.spec.ts} +2 -10
  69. package/src/vpc/VpcTag.spec.tsx +37 -0
  70. package/src/vpc/vpc.module.ts +6 -2
  71. package/dist/vpc/vpcTag.directive.d.ts +0 -2
  72. package/src/image/image.reader.spec.js +0 -123
  73. package/src/instance/awsInstanceType.service.js +0 -437
  74. package/src/vpc/vpcTag.directive.js +0 -34
  75. package/src/vpc/vpcTag.directive.spec.js +0 -60
@@ -1,437 +0,0 @@
1
- 'use strict';
2
-
3
- import { module } from 'angular';
4
- import _ from 'lodash';
5
-
6
- import { REST } from '@spinnaker/core';
7
- import { AWSProviderSettings } from '../aws.settings';
8
-
9
- export const AMAZON_INSTANCE_AWSINSTANCETYPE_SERVICE = 'spinnaker.amazon.instanceType.service';
10
- export const name = AMAZON_INSTANCE_AWSINSTANCETYPE_SERVICE; // for backwards compatibility
11
- module(AMAZON_INSTANCE_AWSINSTANCETYPE_SERVICE, []).factory('awsInstanceTypeService', [
12
- '$q',
13
- function ($q) {
14
- const m5 = {
15
- type: 'm5',
16
- description:
17
- 'm5 instances provide a balance of compute, memory, and network resources. They are a good choice for most applications.',
18
- instanceTypes: [
19
- {
20
- name: 'm5.large',
21
- label: 'Large',
22
- cpu: 2,
23
- memory: 8,
24
- storage: { type: 'EBS' },
25
- costFactor: 2,
26
- },
27
- {
28
- name: 'm5.xlarge',
29
- label: 'XLarge',
30
- cpu: 4,
31
- memory: 16,
32
- storage: { type: 'EBS' },
33
- costFactor: 3,
34
- },
35
- {
36
- name: 'm5.2xlarge',
37
- label: '2XLarge',
38
- cpu: 8,
39
- memory: 32,
40
- storage: { type: 'EBS' },
41
- costFactor: 4,
42
- },
43
- ],
44
- };
45
-
46
- const t2gp = {
47
- type: 't2',
48
- description:
49
- 't2 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst (e.g. web servers, developer environments and small databases).',
50
- instanceTypes: [
51
- {
52
- name: 't2.small',
53
- label: 'Small',
54
- cpu: 1,
55
- memory: 2,
56
- storage: { type: 'EBS' },
57
- costFactor: 1,
58
- },
59
- {
60
- name: 't2.medium',
61
- label: 'Medium',
62
- cpu: 2,
63
- memory: 4,
64
- storage: { type: 'EBS' },
65
- costFactor: 1,
66
- },
67
- {
68
- name: 't2.large',
69
- label: 'Large',
70
- cpu: 2,
71
- memory: 8,
72
- storage: { type: 'EBS' },
73
- costFactor: 2,
74
- },
75
- {
76
- name: 't2.xlarge',
77
- label: 'XLarge',
78
- cpu: 4,
79
- memory: 16,
80
- storage: { type: 'EBS' },
81
- costFactor: 3,
82
- },
83
- {
84
- name: 't2.2xlarge',
85
- label: '2XLarge',
86
- cpu: 8,
87
- memory: 32,
88
- storage: { type: 'EBS' },
89
- costFactor: 4,
90
- },
91
- ],
92
- };
93
-
94
- const t3gp = {
95
- type: 't3',
96
- description:
97
- 't3 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst (e.g. web servers, developer environments and small databases).',
98
- instanceTypes: [
99
- {
100
- name: 't3.small',
101
- label: 'Small',
102
- cpu: 2,
103
- memory: 2,
104
- storage: { type: 'EBS' },
105
- costFactor: 1,
106
- },
107
- {
108
- name: 't3.medium',
109
- label: 'Medium',
110
- cpu: 2,
111
- memory: 4,
112
- storage: { type: 'EBS' },
113
- costFactor: 1,
114
- },
115
- {
116
- name: 't3.large',
117
- label: 'Large',
118
- cpu: 2,
119
- memory: 8,
120
- storage: { type: 'EBS' },
121
- costFactor: 2,
122
- },
123
- {
124
- name: 't3.xlarge',
125
- label: 'XLarge',
126
- cpu: 4,
127
- memory: 16,
128
- storage: { type: 'EBS' },
129
- costFactor: 3,
130
- },
131
- {
132
- name: 't3.2xlarge',
133
- label: '2XLarge',
134
- cpu: 8,
135
- memory: 32,
136
- storage: { type: 'EBS' },
137
- costFactor: 4,
138
- },
139
- ],
140
- };
141
-
142
- const t2 = {
143
- type: 't2',
144
- description:
145
- 't2 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst (e.g. web servers, developer environments and small databases).',
146
- instanceTypes: [
147
- {
148
- name: 't2.nano',
149
- label: 'Nano',
150
- cpu: 1,
151
- memory: 0.5,
152
- storage: { type: 'EBS' },
153
- costFactor: 1,
154
- },
155
- {
156
- name: 't2.micro',
157
- label: 'Micro',
158
- cpu: 1,
159
- memory: 1,
160
- storage: { type: 'EBS' },
161
- costFactor: 1,
162
- },
163
- {
164
- name: 't2.small',
165
- label: 'Small',
166
- cpu: 1,
167
- memory: 2,
168
- storage: { type: 'EBS' },
169
- costFactor: 1,
170
- },
171
- ],
172
- };
173
-
174
- const t3 = {
175
- type: 't3',
176
- description:
177
- 't3 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst (e.g. web servers, developer environments and small databases).',
178
- instanceTypes: [
179
- {
180
- name: 't3.nano',
181
- label: 'Nano',
182
- cpu: 2,
183
- memory: 0.5,
184
- storage: { type: 'EBS' },
185
- costFactor: 1,
186
- },
187
- {
188
- name: 't3.micro',
189
- label: 'Micro',
190
- cpu: 2,
191
- memory: 1,
192
- storage: { type: 'EBS' },
193
- costFactor: 1,
194
- },
195
- {
196
- name: 't3.small',
197
- label: 'Small',
198
- cpu: 2,
199
- memory: 2,
200
- storage: { type: 'EBS' },
201
- costFactor: 1,
202
- },
203
- ],
204
- };
205
-
206
- const r5 = {
207
- type: 'r5',
208
- description:
209
- 'r5 instances are optimized for memory-intensive applications and have the lowest cost per GiB of RAM among Amazon EC2 instance types.',
210
- instanceTypes: [
211
- {
212
- name: 'r5.large',
213
- label: 'Large',
214
- cpu: 2,
215
- memory: 16,
216
- storage: { type: 'EBS' },
217
- costFactor: 1,
218
- },
219
- {
220
- name: 'r5.xlarge',
221
- label: 'XLarge',
222
- cpu: 4,
223
- memory: 32,
224
- storage: { type: 'EBS' },
225
- costFactor: 2,
226
- },
227
- {
228
- name: 'r5.2xlarge',
229
- label: '2XLarge',
230
- cpu: 8,
231
- memory: 64,
232
- storage: { type: 'EBS' },
233
- costFactor: 2,
234
- },
235
- {
236
- name: 'r5.4xlarge',
237
- label: '4XLarge',
238
- cpu: 16,
239
- memory: 128,
240
- storage: { type: 'EBS' },
241
- costFactor: 3,
242
- },
243
- ],
244
- };
245
-
246
- const defaultCategories = [
247
- {
248
- type: 'general',
249
- label: 'General Purpose',
250
- families: [m5, t2gp, t3gp],
251
- icon: 'hdd',
252
- },
253
- {
254
- type: 'memory',
255
- label: 'High Memory',
256
- families: [r5],
257
- icon: 'hdd',
258
- },
259
- {
260
- type: 'micro',
261
- label: 'Micro Utility',
262
- families: [t2, t3],
263
- icon: 'hdd',
264
- },
265
- {
266
- type: 'custom',
267
- label: 'Custom Type',
268
- families: [],
269
- icon: 'asterisk',
270
- },
271
- ];
272
-
273
- const categories = defaultCategories
274
- .filter(({ type }) => !_.get(AWSProviderSettings, 'instanceTypes.exclude.categories', []).includes(type))
275
- .map((category) =>
276
- Object.assign({}, category, {
277
- families: category.families.filter(
278
- ({ type }) => !_.get(AWSProviderSettings, 'instanceTypes.exclude.families', []).includes(type),
279
- ),
280
- }),
281
- );
282
-
283
- function getCategories() {
284
- return $q.when(categories);
285
- }
286
-
287
- const getAllTypesByRegion = function getAllTypesByRegion() {
288
- return REST('/instanceTypes')
289
- .get()
290
- .then(function (types) {
291
- return _.chain(types)
292
- .map(function (type) {
293
- return {
294
- region: type.region,
295
- account: type.account,
296
- name: type.name,
297
- key: [type.region, type.account, type.name].join(':'),
298
- };
299
- })
300
- .uniqBy('key')
301
- .groupBy('region')
302
- .value();
303
- });
304
- };
305
-
306
- const instanceClassOrder = ['xlarge', 'large', 'medium', 'small', 'micro', 'nano'];
307
-
308
- function sortTypesByFamilyAndSize(o1, o2) {
309
- const type1 = o1.split('.');
310
- const type2 = o2.split('.');
311
-
312
- const [family1, class1 = ''] = type1;
313
- const [family2, class2 = ''] = type2;
314
-
315
- if (family1 !== family2) {
316
- if (family1 > family2) {
317
- return 1;
318
- } else if (family1 < family2) {
319
- return -1;
320
- }
321
- return 0;
322
- }
323
-
324
- const t1Idx = instanceClassOrder.findIndex((el) => class1.endsWith(el));
325
- const t2Idx = instanceClassOrder.findIndex((el) => class2.endsWith(el));
326
-
327
- if (t1Idx === -1 || t2Idx === -1) {
328
- return 0;
329
- }
330
-
331
- if (t1Idx === 0 && t2Idx === 0) {
332
- const size1 = parseInt(class1.replace('xlarge', '')) || 0;
333
- const size2 = parseInt(class2.replace('xlarge', '')) || 0;
334
-
335
- if (size2 < size1) {
336
- return 1;
337
- } else if (size2 > size1) {
338
- return -1;
339
- }
340
- return 0;
341
- }
342
-
343
- if (t1Idx > t2Idx) {
344
- return -1;
345
- } else if (t1Idx < t2Idx) {
346
- return 1;
347
- }
348
- return 0;
349
- }
350
-
351
- function getAvailableTypesForRegions(availableRegions, selectedRegions) {
352
- selectedRegions = selectedRegions || [];
353
- let availableTypes = [];
354
-
355
- // prime the list of available types
356
- if (selectedRegions && selectedRegions.length) {
357
- availableTypes = _.map(availableRegions[selectedRegions[0]], 'name');
358
- }
359
-
360
- // this will perform an unnecessary intersection with the first region, which is fine
361
- selectedRegions.forEach(function (selectedRegion) {
362
- if (availableRegions[selectedRegion]) {
363
- availableTypes = _.intersection(availableTypes, _.map(availableRegions[selectedRegion], 'name'));
364
- }
365
- });
366
-
367
- return availableTypes.sort(sortTypesByFamilyAndSize);
368
- }
369
-
370
- const families = {
371
- paravirtual: ['c1', 'c3', 'hi1', 'hs1', 'm1', 'm2', 'm3', 't1'],
372
- hvm: ['c3', 'c4', 'd2', 'i2', 'g2', 'm3', 'm4', 'm5', 'p2', 'r3', 'r4', 'r5', 't2', 'x1'],
373
- vpcOnly: ['c4', 'm4', 'm5', 'r4', 'r5', 't2', 'x1'],
374
- ebsOptimized: ['c4', 'd2', 'f1', 'g3', 'i3', 'm4', 'm5', 'p2', 'r4', 'r5', 'x1'],
375
- burstablePerf: ['t2', 't3', 't3a', 't4g'],
376
- };
377
-
378
- function filterInstanceTypes(instanceTypes, virtualizationType, vpcOnly) {
379
- return instanceTypes.filter((instanceType) => {
380
- if (virtualizationType === '*') {
381
- // show all instance types
382
- return true;
383
- }
384
- const [family] = instanceType.split('.');
385
- if (!vpcOnly && families.vpcOnly.includes(family)) {
386
- return false;
387
- }
388
- if (!families.paravirtual.includes(family) && virtualizationType === 'hvm') {
389
- return true;
390
- }
391
- return families[virtualizationType].includes(family);
392
- });
393
- }
394
-
395
- function isEbsOptimized(instanceType) {
396
- if (!instanceType) {
397
- return false;
398
- }
399
- const [family] = instanceType.split('.');
400
- return families.ebsOptimized.includes(family);
401
- }
402
-
403
- function isBurstingSupported(instanceType) {
404
- if (!instanceType) {
405
- return false;
406
- }
407
- const [family] = instanceType.split('.');
408
- return families.burstablePerf.includes(family);
409
- }
410
-
411
- function isInstanceTypeInCategory(instanceType, category) {
412
- if (!instanceType || !category) {
413
- return false;
414
- }
415
-
416
- if (category === 'custom') {
417
- return true;
418
- }
419
-
420
- const [family] = instanceType.split('.');
421
- const instanceCategory = _.find(defaultCategories, { type: category });
422
- const familyInCategory = instanceCategory && _.find(instanceCategory.families, { type: family });
423
-
424
- return familyInCategory && familyInCategory.instanceTypes.map((t) => t.name).includes(instanceType);
425
- }
426
-
427
- return {
428
- getCategories,
429
- getAvailableTypesForRegions,
430
- getAllTypesByRegion,
431
- filterInstanceTypes,
432
- isEbsOptimized,
433
- isBurstingSupported,
434
- isInstanceTypeInCategory,
435
- };
436
- },
437
- ]);
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- import { module } from 'angular';
4
-
5
- import { VpcReader } from '../vpc/VpcReader';
6
-
7
- export const AMAZON_VPC_VPCTAG_DIRECTIVE = 'spinnaker.amazon.vpc.tag.directive';
8
- export const name = AMAZON_VPC_VPCTAG_DIRECTIVE; // for backwards compatibility
9
- module(AMAZON_VPC_VPCTAG_DIRECTIVE, []).directive('vpcTag', function () {
10
- return {
11
- restrict: 'E',
12
- scope: {
13
- vpcId: '=',
14
- },
15
- template: '<span class="vpc-tag">{{vpcLabel}}</span>',
16
- link: function (scope) {
17
- function applyLabel() {
18
- if (!scope.vpcId) {
19
- scope.vpcLabel = 'None (EC2 Classic)';
20
- } else {
21
- VpcReader.getVpcName(scope.vpcId).then(function (name) {
22
- scope.vpcLabel = '(' + scope.vpcId + ')';
23
-
24
- if (name) {
25
- scope.vpcLabel = name + ' ' + scope.vpcLabel;
26
- }
27
- });
28
- }
29
- }
30
-
31
- scope.$watch('vpcId', applyLabel, true);
32
- },
33
- };
34
- });
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- import { VpcReader } from '../vpc/VpcReader';
4
-
5
- describe('Directives: vpcTag', function () {
6
- var $q;
7
-
8
- beforeEach(window.module(require('./vpcTag.directive').name));
9
-
10
- beforeEach(
11
- window.inject(function ($rootScope, $compile, _$q_) {
12
- this.scope = $rootScope.$new();
13
- this.compile = $compile;
14
- $q = _$q_;
15
- }),
16
- );
17
-
18
- describe('vpc tag rendering - no VPC provided', function () {
19
- it('displays default message when no vpcId supplied', function () {
20
- var domNode = this.compile('<vpc-tag></vpc-tag>')(this.scope);
21
- this.scope.$digest();
22
- expect(domNode.find('span').text()).toBe('None (EC2 Classic)');
23
- });
24
-
25
- it('displays default message when undefined vpcId supplied', function () {
26
- var domNode = this.compile('<vpc-tag vpc-id="notDefined"></vpc-tag>')(this.scope);
27
- this.scope.$digest();
28
- expect(domNode.find('span').text()).toBe('None (EC2 Classic)');
29
- });
30
-
31
- it('displays default message when null vpcId supplied', function () {
32
- this.scope.vpcId = null;
33
- var domNode = this.compile('<vpc-tag vpc-id="vpcId"></vpc-tag>')(this.scope);
34
- this.scope.$digest();
35
- expect(domNode.find('span').text()).toBe('None (EC2 Classic)');
36
- });
37
- });
38
-
39
- describe('vpc tag rendering - VPC provided', function () {
40
- it('displays vpc name when found', function () {
41
- spyOn(VpcReader, 'getVpcName').and.callFake(function () {
42
- return $q.when('Main VPC');
43
- });
44
- this.scope.vpcId = 'vpc-1';
45
- var domNode = this.compile('<vpc-tag vpc-id="vpcId"></vpc-tag>')(this.scope);
46
- this.scope.$digest();
47
- expect(domNode.find('span').text()).toBe('Main VPC (vpc-1)');
48
- });
49
-
50
- it('displays vpc id when not found', function () {
51
- spyOn(VpcReader, 'getVpcName').and.callFake(function () {
52
- return $q.when(null);
53
- });
54
- this.scope.vpcId = 'vpc-2';
55
- var domNode = this.compile('<vpc-tag vpc-id="vpcId"></vpc-tag>')(this.scope);
56
- this.scope.$digest();
57
- expect(domNode.find('span').text()).toBe('(vpc-2)');
58
- });
59
- });
60
- });