my $instances = $ec2->run_instances( ImageId => $ami_id, MinCount => 1, MaxCount => 1, KeyName => $key, (defined $user_data ? (UserData => MIME::Base64::encode_base64($user_data)) : ()), (defined $instance_type ? (InstanceType => $instance_type) : ()), #... ) or die "$ec2->{error}";