GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp
PERMISSION_DENIED when provisioning ProducerDestination in spring-cloud-gcp-pubsub-stream-binder
- Dominant language
- Java
- Stars
- 551
- Forks
- 349
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 14
Description
Hi Team,
Putting this bug related to Producer Destination , Earlier you guys fixed similar kind of issue for Consumer Destination as part of this ticket https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/1348. On the similar note you also need to fix it for Producer Destination, it still exists for ProducerDestination in latest 5.6.0 version in PubSubChannelProvisioner._ It uselessly enter into ensureTopicExists method and search for this.pubSubAdmin.getTopic(topicName) while auto-create-resources=false that required additional pubsub.get.topics permission for SA .
Current Implementation:
```
@Override
public ProducerDestination provisionProducerDestination(
String topic, ExtendedProducerProperties properties) {
ensureTopicExists(topic, properties.getExtension().isAutoCreateResources());
return new PubSubProducerDestination(topic);
}
```
Required Implementation:
```
@Override
public ProducerDestination provisionProducerDestination(
String topic, ExtendedProducerProperties properties) {
boolean autoCreate = properties.getExtension().isAutoCreateResources();
// topicName may be either the short or fully-qualified version.
String topicShortName =
TopicName.isParsableFrom(topicName) ? TopicName.parse(topicName).getTopic() : topicName;
if (autoCreate) {
ensureTopicExists(topicShortName, autoCreate);
}
return new PubSubProducerDestination(topic);
}
```
Please fixed it and update us here !
Contributor guide
Assessment
This issue has not been assessed yet.