We would like to have a service account with access only to subscribe to a topic and not t to publish or create anything else than create its subscription on one topic if the subscription doesn't exists.
Given the code below what is needed to get it to work without granting access to the actual project?
private static void ensureTopicAndSubscriptionExist(
PubSub pubsub, String topic, String subscription) {
if (pubsub.getTopic(topic) == null) {
throw new IllegalStateException("Topic does not exist: " + topic);
}
if (pubsub.getSubscription(subscription) == null) {
LOG.info("creating PubSub subscription={} for topic={}", subscription, topic);
pubsub.create(SubscriptionInfo.of(topic, subscription));
LOG.info("created PubSub subscription={} for topic={}", subscription, topic);
}
}
We only get this to work if the service account user has edit rights on the project
We would like to have a service account with access only to subscribe to a topic and not t to publish or create anything else than create its subscription on one topic if the subscription doesn't exists.
Given the code below what is needed to get it to work without granting access to the actual project?
We only get this to work if the service account user has edit rights on the project