func()

in lib/ec2macosinit/imds.go [92:110]


func (i *IMDSConfig) UpdateInstanceID() (err error) {
	// If instance ID is already set, this doesn't need to be run
	if i.InstanceID != "" {
		return nil
	}

	// Get IMDS property "meta-data/instance-id"
	i.InstanceID, _, err = i.getIMDSProperty("meta-data/instance-id")
	if err != nil {
		return fmt.Errorf("ec2macosinit: error getting instance ID from IMDS: %s\n", err)
	}

	// Validate that an ID was returned
	if i.InstanceID == "" {
		return fmt.Errorf("ec2macosinit: an empty instance ID was returned from IMDS\n")
	}

	return nil
}