How to attach a 2x beam to the side of a post?
If the 2X stock is part of the supporting structure such as a wrap or beam attached to a post,  it must be secured by a threaded device, not nails unless it is held by a metal support. Local codes vary a lot on this type of connection, but IRC simply calls for a threaded device in applications like this.  A through bolt is always a good choice, but sometimes lags work well because of limited access to the back of the post. Usually two per union is good, 5/16"  to 3/8" is usually fine, but 3 pieces and a bit larger may be better if the 2X stock is larger like 2X12.   You can use a 10d nail or two to hold your stock in place while you drill or pilot for your threaded device. When you drill for your bolts, be sure to use the exact size bit or under size the hole by 1/32" so your bolts will fit extra snug. Drive them in with a hammer. Never oversize the hole just to make insertion easier. Get a bigger hammer!