2008 GMC Canyon won’t start unless ignition switch is on

what causes truck to not start until you leave the ignition switch in the on position for 10 minutes with security light flashing, when light stops flashing turn key off then starts normally?

Does the engine crank but not start? Might be a weak fuel pump. If it does not crank then maybe the ignition switch is bad. Any CEL codes?