Hi Abhishek,
I attempted to reproduce your issue but I was able to successfully publish my messages using Cloud Functions.
Environment:
Cloud Function Service Account only has Cloud Function Service Agent role
It may be that the Project ID you supplied within your code is incorrect which could cause your code to attempt publishing messages to a topic in another project.
Do note that Google Groups is reserved for general product discussions. If you require further technical support in the future, we would recommended posting your
detailed questions on Stack Exchange using the
supported tags as a dedicated support team handles these requests.