I have setup a PubSub subscription to push authenticated HTTPS requests to my AppEngine application sitting behind Cloud IAP. With IAP disabled, the requests come through fine - I even logged the Authorization token header and tried it via cURL with IAP enabled again and it works. So I can validate that PubSub is sending the correct token but with IAP enabled, the request never reaches my service.
What I did to troubleshoot:
- Manually send an event to the topic
- Monitor logs for AppEngine service and see nothing come through
- Disable Cloud IAP for AppEngine service
- Monitor logs for AppEngine service and see the request come through as expected, logged all headers
- Enabled Cloud IAP for AppEngine service
- Tried a POST cURL request using Authorization header logged when Cloud IAP was disabled
- Monitor logs for AppEngine and see cURL request come through
Setup:
gcloud beta iam service-accounts create cron-service-accessor --description="Only this user is authorized to make requests to the Cron service on AppEngine" --display-name="Cron Service Accessor" --project=$PROJECT_ID
gcloud beta iap web add-iam-policy-binding --member=serviceAccount:cron-service-accessor@$PROJECT_ID.iam.gserviceaccount.com --role="roles/iap.httpsResourceAccessor" --service=cron --resource-type=app-engine --project=$PROJECT_ID export PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID | grep projectNumber | cut -d "'" -f 2 -)
gcloud beta pubsub topics create files-topic --project=$PROJECT_ID
A similar setup is working with Cron Scheduler, using the oidc authentication options available there for the request. I even came across this StackOverflow question where some users are reporting they got it to work and others (more recently, within the past few weeks) are reporting it does not work.
Is there an issue with PubSub preventing this mechanism from working? Does a project age have anything to do with it?
I'd appreciate any help/guidance on the matter.
Thank you,
Prateek