如何将Spring Cloud GCP用于多个Google项目 [英] How to use Spring Cloud GCP for multiple google projects

查看:192
本文介绍了如何将Spring Cloud GCP用于多个Google项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于那些非常了解GCP的人来说,它对用户和权限控制有一些局限性".

For those who knows GCP well, it has some "limitations" about user and permissions control.

例如,数据存储区没有任何方法来管理数据库本身的用户角色,并且仅具有平台的IAM.

The Datastore, for example, doesn't have any way to manage user roles of the database itself and it has only the IAM of the plataform.

因此,Google的员工建议其客户使用GCP的多个项目和文件夹来对此进行更多控制.我已经看了一段时间了.

Because of that, Google's employees advise their customers to use multiple projects and folders of the GCP to have more control in that. I have seen it for a while.

问题是:如何在Spring Cloud GCP上连接到GCP多个项目的多个资源?我们的应用程序应从不同的项目访问数据存储区和其他资源,我在此方面苦苦挣扎.

The question is: How to connect to multiple resources of multiple projects of GCP on Spring Cloud GCP? We have applications that should access Datastore and other resources from different projects and I'm struggling here with that.

即使Spring Cloud GCP不支持多个GCP项目,是否有解决方法?

Even if Spring Cloud GCP doesn't support for multiple GCP projects, there is any workaround?

谢谢大家.

推荐答案

您可以使用为每个单独的服务提供的低级客户端库,使用如下提供的构建器来创建实例,以便将pubsub发布到具有不同项目ID的主题

You can use low-level client libraries provided for each individual service, to create an instance using builder provided like below for pubsub publishing to a topic with different project id.

ProjectTopicName topicName = ProjectTopicName.of(projectId, topic);
publisher = Publisher.newBuilder(topicName)
                        .setChannelProvider(transportChannelProvider)
                        .setCredentialsProvider(credentialsProvider)
                        .build();

然后,您可以创建一个bean并在您的应用程序中将其自动连接以使用它. 尽管要使用带有多个项目ID的spring-cloud-gcp-pubsub,您可以参考

You can then create a bean and autowire this in your app to use it. Although for using spring-cloud-gcp-pubsub with multiple project ids you can refer this answer

这篇关于如何将Spring Cloud GCP用于多个Google项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆