Description
There is a logical error with the check to see if the environment is an EC2 machine. Because of this, on first run it tries to ping a non existent EC2 server which causes a delay of 30 seconds while waiting for the check to complete.
In the code snippet below, any one of the conditions will allow checking of EC2
- Config.IsEc2 == null
- Config.IsEc2 == true
- isDefaultDeviceNameEc2
Condition 1 is checking if the variable is null - e.g. no value is set. On loading our configuration, IsEc2 is null, in which case it meets the condition and calls GetEC2InstanceId(). This call will eventually fail but require waiting for 20-30 seconds while it tries to connect to Ec2.
The condition could be written as if ((Config.IsEc2.HasValue && Config.IsEc2) || isDefaultDeviceNameEc2)
Note, that after the first run the values are cached so no further attempts at connecting with Ec2 is made.