GeezerVison is showing github.com — Permissions problem trying to create a sink · Issue #1614 · googleapis/google-cloud-python
Permissions problem trying to create a sink #1614DescriptionWhile working on a system test for Sink.create, I'm running into a permissions problem:
>>> sink.create()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "gcloud/logging/sink.py", line 145, in create
client.connection.api_request(method='PUT', path=self.path, data=data)
File "gcloud/connection.py", line 343, in api_request
error_info=method + ' ' + url)
gcloud.exceptions.Forbidden: 403 The caller does not have permission (PUT https://logging.googleapis.com/v2beta1/projects/citric-celerity-697/sinks/test-sink)
Sinks.create is documented to require one of https://www.googleapis.com/auth/logging.admin or https://www.googleapis.com/auth/cloud-platform.
My client is set up with all permissions for the logging API:
>>> client.connection._credentials._scopes
'https://www.googleapis.com/auth/logging.read https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/logging.admin https://www.googleapis.com/auth/cloud-platform'
Do I have to do something in the developer control panel to enable sinks? Activitytseaver commented on Mar 15, 2016 ContributorAuthor More actions @jgeewax please loop in whoever would be able to point me in the right direction from the logging API team. tseaver commented on Mar 15, 2016 ContributorAuthor More actions tseaver commented on Mar 15, 2016 ContributorAuthor More actions More likely an error on my part: the failed request was trying to do a PUT to the URL of the sink, which doesn't yet exist, instead of a POST to the /sinks quasi-container. tseaver commented on Mar 15, 2016 ContributorAuthor More actions But I'm betting that when I do get that part right, then the 403 will trigger because I don't have the bucket permissions set correctly. tseaver commented on Mar 15, 2016 ContributorAuthor More actions Grrr. Switching to POST doesn't fix it:
gcloud.exceptions.Forbidden: 403 The caller does not have permission (POST https://logging.googleapis.com/v2beta1/projects/citric-celerity-697/sinks)
That same URI works fine in the API Exploder. dhermes commented on Mar 16, 2016 dhermes commented on Mar 16, 2016 stephenplusplus commented on Mar 16, 2016 stephenplusplus commented on Mar 16, 2016 blowmage commented on Mar 16, 2016 IIRC the Pub/Sub IAM issue is different. The issue with creating Logging Sinks is that it requires a user account, not a service account. This is imposed by the API, and there isn't much we can do to get around it. @quartzmo, does that sound right? stephenplusplus commented on Mar 16, 2016 Ah, my bad. We were getting errors creating Sinks with a Pub/Sub Topic as a destination, which traces back to the Pub/Sub IAM change, so I jumped at a connection between that issue and this one.
Indeed, you must be authenticated as a user (through the gcloud SDK works). Here's the official word from a Logging member: googleapis/google-cloud-node#842 (comment) blowmage commented on Mar 16, 2016 There are some additional steps for creating a sink to a Bucket, and @quartzmo was chasing that info down for our docs, so I'll defer to him on that as well. 😅 quartzmo commented on Mar 16, 2016 Unfortunately I haven't gotten it working yet, but I'll try again today.
On Mar 16, 2016, at 7:02 AM, Mike Moore [email protected] wrote:
There are some additional steps for creating a sink to a Bucket, and @quartzmo was chasing that info down for our docs, so I'll defer to him on that as well. 😅
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
tseaver commented on Mar 17, 2016 ContributorAuthor More actions @blowmage wrote:
The issue with creating Logging Sinks is that it requires a user account, not a service account. This is imposed by the API, and there isn't much we can do to get around it.
@jgeewax Is there someplace where we can at least "argue with the ref" about this restriction? It seems perverse to deny service accounts the ability create logging sinks, when they can create and delete storage buckets, pubsub topics, bigquery datasets, bigtable clusters, etc. blowmage commented on Mar 17, 2016 I agree it would be nice if the service did this for us. My guess is that it has to do with Storage not using IAM for permissions.
Is adding permissions to the bucket something we should do in our libraries when creating a sink? tseaver commented on Mar 17, 2016 ContributorAuthor More actions
I agree it would be nice if the service did this for us. My guess is that it has to do with Storage not using IAM for permissions.
Pubsub uses IAM, and allows service accounts to create topics / subscriptions.
Is adding permissions to the bucket something we should do in our libraries when creating a sink?
Good question. Doing so "magically" would feel wrong to me. Maybe we should expose convenience functions, e.g., prepare_bucket_for_logging, prepare_topic_for_logging, and prepare_dataset_for_logging, which would make the needed permissions / role changes. quartzmo commented on Mar 17, 2016 @blowmage Great question, but I agree with @tseaver that adding permissions automatically seems like going a bit too far. I think showing that it is required in the examples is good enough. tseaver commented on Mar 17, 2016 ContributorAuthor More actions FWIW, the logging API docs say:
You must have owner permission to the project whose logs are being exported.
I thought I had read (in the docs for setIamPolicy) that system accounts could not be granted the Owner permission. However, from the console permissions page, I was able to assign it to my service account, which then allows that account to create / delete sink resources.
@jgeewax we will need to ensure that the system account used by Travis has the Owner role before merging the sink-related system tests. dhermes commented on Mar 18, 2016 @tseaver Do you have access to edit that project in the Cloud Console? tseaver commented on Mar 18, 2016 ContributorAuthor More actions @dhermes The only project which shows up for me in the "Manage all projects" view is my own. dhermes commented on Mar 18, 2016 OK. I can make the changes. Send me an email with the changes you want?
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|