My app uses a Cloud Function (2nd gen), running multiple instances and triggered by PubSub, to make outbound requests to customers sites (essentially for synthetic monitoring).
However, the platform several of those sites are hosted on has bot protection, and I've been told by the company they don't have a way of whitelisting IPs for it, so it would be best if I rotate through IPs (ie a Function selects/is assigned an IP when created).
Cloud NAT seems to be the recommendation for setting up static external IPs, but adding multiple IPs there doesn't cycle through them until they reach TCP connection limits.
Load balancers might have a way to do it, but from what I've found, egress is still routed through Cloud NAT, and uses the IP assigned there.
Is there another way to make requests from Cloud Functions from varying IPs?
Now that specific Cloud Function using that specific VPC Connector will route its outbound traffic through that specific Cloud NAT Gateway.
You can repeat this process as many times as necessary. To make this work with your Cloud Function you will have to deploy them as multiple Cloud Functions rather than a single Cloud Function. For example, if you presently have a function named myCloudFunction then you would need to deploy it as three separate and distinct Cloud Functions, each using a different configuration:
You would then need to find a way to load balance the requests across those three functions, for example with another Cloud Function whose job it is to send the request through those functions. My recommendation would be something like: