Skip to content

Commit e5d2e4b

Browse files
author
marc
committed
Add back logic for EC2 names.
1 parent d6eb954 commit e5d2e4b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Src/StackifyLib/Models/EnvironmentDetail.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ public static string GetDeviceName()
118118
//WIN-230 - Set DeviceName to Environment.MachineName.
119119
deviceName = Environment.MachineName;
120120

121+
var isDefaultDeviceNameEc2 = IsEc2MachineName(deviceName);
122+
123+
if (Config.IsEc2 == null || Config.IsEc2 == true || isDefaultDeviceNameEc2)
124+
{
125+
var instanceID_task = GetEC2InstanceId();
126+
instanceID_task.Wait();
127+
if (string.IsNullOrWhiteSpace(instanceID_task.Result) == false)
128+
{
129+
deviceName = instanceID_task.Result;
130+
}
131+
}
132+
121133
return deviceName.Substring(0, deviceName.Length > 60 ? 60 : deviceName.Length);
122134
}
123135

@@ -192,6 +204,18 @@ public static string GetDeviceName()
192204
//WIN-230 - Set DeviceName to Environment.MachineName.
193205
deviceName = Environment.MachineName;
194206

207+
var isDefaultDeviceNameEc2 = IsEc2MachineName(deviceName);
208+
209+
if (Config.IsEc2 == null || Config.IsEc2 == true || isDefaultDeviceNameEc2)
210+
{
211+
var instanceID_task = GetEC2InstanceId();
212+
instanceID_task.Wait();
213+
if (string.IsNullOrWhiteSpace(instanceID_task.Result) == false)
214+
{
215+
deviceName = instanceID_task.Result;
216+
}
217+
}
218+
195219
return deviceName.Substring(0, deviceName.Length > 60 ? 60 : deviceName.Length);
196220
}
197221

0 commit comments

Comments
 (0)