1- import cuid from 'cuid'
1+ import { generateUniqueId } from '@cloudgraph/sdk'
2+
23import t from '../../properties/translations'
3- import { AwsAsg } from '../../types/generated' ;
4- import { formatTagsFromMap } from '../../utils/format' ;
5- import { RawAwsAsg } from './data' ;
4+ import { AwsAsg } from '../../types/generated'
5+ import { formatTagsFromMap } from '../../utils/format'
6+ import { RawAwsAsg } from './data'
67
78export default ( {
89 service : rawData ,
@@ -49,54 +50,78 @@ export default ({
4950
5051 const ec2InstanceIds = instances . map ( ( { InstanceId } ) => InstanceId )
5152
52- const launchTemplateOverrideList = mixedInstancesPolicy ?. LaunchTemplate ?. Overrides . map ( ( {
53- InstanceType : instanceType ,
54- WeightedCapacity : weightedCapacity ,
55- LaunchTemplateSpecification : launchTemplateSpecification ,
56- } ) => {
57- return {
58- id : cuid ( ) ,
59- instanceType,
60- weightedCapacity,
61- launchTemplateId : launchTemplateSpecification ?. LaunchTemplateId || '' ,
62- launchTemplateName : launchTemplateSpecification ?. LaunchTemplateName || '' ,
63- launchTemplateVersion : launchTemplateSpecification ?. Version || '' ,
64- }
65- } ) || [ ] ;
53+ const launchTemplateOverrideList =
54+ mixedInstancesPolicy ?. LaunchTemplate ?. Overrides . map (
55+ ( {
56+ InstanceType : instanceType ,
57+ WeightedCapacity : weightedCapacity ,
58+ LaunchTemplateSpecification : launchTemplateSpecification ,
59+ } ) => {
60+ return {
61+ id : generateUniqueId ( {
62+ arn,
63+ instanceType,
64+ weightedCapacity,
65+ launchTemplateSpecification,
66+ } ) ,
67+ instanceType,
68+ weightedCapacity,
69+ launchTemplateId : launchTemplateSpecification ?. LaunchTemplateId || '' ,
70+ launchTemplateName :
71+ launchTemplateSpecification ?. LaunchTemplateName || '' ,
72+ launchTemplateVersion : launchTemplateSpecification ?. Version || '' ,
73+ }
74+ }
75+ ) || [ ]
76+
77+ const suspendedProcessList =
78+ suspendedProcesses . map (
79+ ( { ProcessName : processName , SuspensionReason : suspensionReason } ) => {
80+ return {
81+ id : generateUniqueId ( {
82+ arn,
83+ processName,
84+ suspensionReason,
85+ } ) ,
86+ processName,
87+ suspensionReason,
88+ }
89+ }
90+ ) || [ ]
6691
67- const suspendedProcessList = suspendedProcesses . map ( ( {
68- ProcessName : processName ,
69- SuspensionReason : suspensionReason ,
70- } ) => {
71- return {
72- id : cuid ( ) ,
73- processName,
74- suspensionReason,
75- } } ) || [ ] ;
92+ const enabledMetricsList =
93+ enabledMetrics . map ( ( { Metric : metric , Granularity : granularity } ) => {
94+ return {
95+ id : generateUniqueId ( {
96+ arn,
97+ metric,
98+ granularity,
99+ } ) ,
100+ metric,
101+ granularity,
102+ }
103+ } ) || [ ]
76104
77- const enabledMetricsList = enabledMetrics . map ( ( {
78- Metric : metric ,
79- Granularity : granularity ,
80- } ) => {
81- return {
82- id : cuid ( ) ,
83- metric,
84- granularity,
85- }
86- } ) || [ ] ;
87-
88- const blockDeviceMappingList = launchConfiguration ?. BlockDeviceMappings ?. map ( ( {
89- VirtualName : virtualName ,
90- DeviceName : deviceName ,
91- NoDevice : noDevice ,
92- } ) => {
93- return {
94- id : cuid ( ) ,
95- virtualName,
96- deviceName,
97- noDevice : noDevice ? t . yes : t . no ,
98- }
99- } ) || [ ]
105+ const blockDeviceMappingList =
106+ launchConfiguration ?. BlockDeviceMappings ?. map (
107+ ( {
108+ VirtualName : virtualName ,
109+ DeviceName : deviceName ,
110+ NoDevice : noDevice ,
111+ } ) => {
112+ return {
113+ id : generateUniqueId ( {
114+ arn,
115+ virtualName,
116+ deviceName,
117+ noDevice,
118+ } ) ,
119+ virtualName,
120+ deviceName,
121+ noDevice : noDevice ? t . yes : t . no ,
122+ }
123+ }
124+ ) || [ ]
100125
101126 return {
102127 id : arn ,
@@ -109,16 +134,31 @@ export default ({
109134 launchTemplateName : launchTemplate ?. LaunchTemplateName || '' ,
110135 launchTemplateVersion : launchTemplate ?. Version || '' ,
111136 mixedInstancesPolicy : {
112- launchTemplateId : mixedInstancesPolicy ?. LaunchTemplate ?. LaunchTemplateSpecification ?. LaunchTemplateId || '' ,
113- launchTemplateName : mixedInstancesPolicy ?. LaunchTemplate ?. LaunchTemplateSpecification ?. LaunchTemplateName || '' ,
114- launchTemplateVersion : mixedInstancesPolicy ?. LaunchTemplate ?. LaunchTemplateSpecification ?. Version || '' ,
137+ launchTemplateId :
138+ mixedInstancesPolicy ?. LaunchTemplate ?. LaunchTemplateSpecification
139+ ?. LaunchTemplateId || '' ,
140+ launchTemplateName :
141+ mixedInstancesPolicy ?. LaunchTemplate ?. LaunchTemplateSpecification
142+ ?. LaunchTemplateName || '' ,
143+ launchTemplateVersion :
144+ mixedInstancesPolicy ?. LaunchTemplate ?. LaunchTemplateSpecification
145+ ?. Version || '' ,
115146 launchTemplateOverrides : launchTemplateOverrideList ,
116- instDistrOnDemandAllocationStrategy : mixedInstancesPolicy ?. InstancesDistribution ?. OnDemandAllocationStrategy || '' ,
117- instDistrOnDemandBaseCapacity : mixedInstancesPolicy ?. InstancesDistribution ?. OnDemandBaseCapacity || 0 ,
118- instDistrOnDemandPercentageAboveBaseCapacity : mixedInstancesPolicy ?. InstancesDistribution ?. OnDemandPercentageAboveBaseCapacity || 0 ,
119- instDistrSpotAllocationStrategy : mixedInstancesPolicy ?. InstancesDistribution ?. SpotAllocationStrategy || '' ,
120- instDistrSpotInstancePools : mixedInstancesPolicy ?. InstancesDistribution ?. SpotInstancePools || 0 ,
121- instDistrSpotMaxPrice : mixedInstancesPolicy ?. InstancesDistribution ?. SpotMaxPrice || '' ,
147+ instDistrOnDemandAllocationStrategy :
148+ mixedInstancesPolicy ?. InstancesDistribution
149+ ?. OnDemandAllocationStrategy || '' ,
150+ instDistrOnDemandBaseCapacity :
151+ mixedInstancesPolicy ?. InstancesDistribution ?. OnDemandBaseCapacity || 0 ,
152+ instDistrOnDemandPercentageAboveBaseCapacity :
153+ mixedInstancesPolicy ?. InstancesDistribution
154+ ?. OnDemandPercentageAboveBaseCapacity || 0 ,
155+ instDistrSpotAllocationStrategy :
156+ mixedInstancesPolicy ?. InstancesDistribution ?. SpotAllocationStrategy ||
157+ '' ,
158+ instDistrSpotInstancePools :
159+ mixedInstancesPolicy ?. InstancesDistribution ?. SpotInstancePools || 0 ,
160+ instDistrSpotMaxPrice :
161+ mixedInstancesPolicy ?. InstancesDistribution ?. SpotMaxPrice || '' ,
122162 } ,
123163 minSize,
124164 maxSize,
@@ -137,39 +177,51 @@ export default ({
137177 enabledMetrics : enabledMetricsList ,
138178 status : status || '' ,
139179 terminationPolicies,
140- newInstancesProtectedFromScaleIn : newInstancesProtectedFromScaleIn ? t . yes : t . no ,
180+ newInstancesProtectedFromScaleIn : newInstancesProtectedFromScaleIn
181+ ? t . yes
182+ : t . no ,
141183 serviceLinkedRoleARN,
142184 maxInstanceLifetime : maxInstanceLifetime || 0 ,
143185 capacityRebalanceEnabled : capacityRebalanceEnabled ? t . yes : t . no ,
144- warmPoolConfigMaxGroupPreparedCapacity : warmPoolConfiguration ?. MaxGroupPreparedCapacity || 0 ,
186+ warmPoolConfigMaxGroupPreparedCapacity :
187+ warmPoolConfiguration ?. MaxGroupPreparedCapacity || 0 ,
145188 warmPoolConfigMinSize : warmPoolConfiguration ?. MinSize || 0 ,
146189 warmPoolConfigPoolState : warmPoolConfiguration ?. PoolState || '' ,
147190 warmPoolConfigStatus : warmPoolConfiguration ?. Status || '' ,
148191 warmPoolSize : warmPoolSize || 0 ,
149192 context : context || '' ,
150193 tags : formatTagsFromMap ( tags ) ,
151194 launchConfiguration : {
152- launchConfigurationName : launchConfiguration ?. LaunchConfigurationName || '' ,
195+ launchConfigurationName :
196+ launchConfiguration ?. LaunchConfigurationName || '' ,
153197 launchConfigurationARN : launchConfiguration ?. LaunchConfigurationARN || '' ,
154198 imageId : launchConfiguration ?. ImageId || '' ,
155199 keyName : launchConfiguration ?. KeyName || '' ,
156200 securityGroups : launchConfiguration ?. SecurityGroups || [ ] ,
157201 classicLinkVPCId : launchConfiguration ?. ClassicLinkVPCId || '' ,
158- classicLinkVPCSecurityGroups : launchConfiguration ?. ClassicLinkVPCSecurityGroups || [ ] ,
202+ classicLinkVPCSecurityGroups :
203+ launchConfiguration ?. ClassicLinkVPCSecurityGroups || [ ] ,
159204 userData : launchConfiguration ?. UserData || '' ,
160205 instanceType : launchConfiguration ?. InstanceType || '' ,
161206 kernelId : launchConfiguration ?. KernelId || '' ,
162207 ramdiskId : launchConfiguration ?. RamdiskId || '' ,
163208 blockDeviceMappings : blockDeviceMappingList ,
164- instanceMonitoring : launchConfiguration ?. InstanceMonitoring ?. Enabled ? t . yes : t . no ,
209+ instanceMonitoring : launchConfiguration ?. InstanceMonitoring ?. Enabled
210+ ? t . yes
211+ : t . no ,
165212 spotPrice : launchConfiguration ?. SpotPrice || '' ,
166213 iamInstanceProfile : launchConfiguration ?. IamInstanceProfile || '' ,
167214 ebsOptimized : launchConfiguration ?. EbsOptimized ? t . yes : t . no ,
168- associatePublicIpAddress : launchConfiguration ?. AssociatePublicIpAddress ? t . yes : t . no ,
215+ associatePublicIpAddress : launchConfiguration ?. AssociatePublicIpAddress
216+ ? t . yes
217+ : t . no ,
169218 placementTenancy : launchConfiguration ?. PlacementTenancy || '' ,
170- metadataOptHttpTokens : launchConfiguration ?. MetadataOptions ?. HttpTokens || '' ,
171- metadataOptHttpPutResponseHopLimit : launchConfiguration ?. MetadataOptions ?. HttpPutResponseHopLimit || 0 ,
172- metadataOptHttpEndpoint : launchConfiguration ?. MetadataOptions ?. HttpEndpoint || '' ,
173- }
219+ metadataOptHttpTokens :
220+ launchConfiguration ?. MetadataOptions ?. HttpTokens || '' ,
221+ metadataOptHttpPutResponseHopLimit :
222+ launchConfiguration ?. MetadataOptions ?. HttpPutResponseHopLimit || 0 ,
223+ metadataOptHttpEndpoint :
224+ launchConfiguration ?. MetadataOptions ?. HttpEndpoint || '' ,
225+ } ,
174226 }
175227}
0 commit comments