How to modularize IAM instance profile of AWS?

Say I have two modules (for different functions), each defines an IAM instance profile. When I use any one of them, I can associate the profile id to my instance. This is fine.

But when I want to use both of them, I cannot figure out how to make it.

Even I tried the get json of the policy documents, assigning them to my (new) IAM instance profile, I do not know how to merge them into one json.