简体   繁体   English

Google Cloud VM实例共享

[英]Google Cloud VM instance Share

I have two vm instance . 我有两个虚拟机实例。 I want to give permission as compute admin to different users for both machines. 我想授予两台计算机的不同用户作为计算管理员的权限。 Means two different owner of two Instance. 表示两个实例的两个不同所有者。

At Google Cloud Next 2018, Google announced Compute Engine resource-level IAM . 在2018年Google Cloud Next上,Google宣布了Compute Engine资源级IAM

Inside a same project, you can now grant directly different roles to your Compute VMs to different users. 在同一个项目中,您现在可以将Compute VM的不同角色直接授予不同的用户。 If your use-case is to have 2 users ( user1@mydomain.com and user2@mydomain.com ), each one admin of a specific instance (relatively instance1 and instance2 ), you can define the following YAML files : 如果您的用例有2个用户( user1@mydomain.comuser2@mydomain.com ),每个实例分别属于一个特定实例(分别是instance1instance2 )的管理员,则可以定义以下YAML文件:

# instance1_policy.yaml

bindings:
- members:
  - user:user1@mydomain.com
  role: roles/compute.admin

and

# instance2_policy.yaml

bindings:
- members:
  - user:user2@mydomain.com
  role: roles/compute.admin

And apply the policies (merge the following files with the existing VMs IAM policies if you need so, check by using gcloud compute instances get-iam-policy before) : 并应用策略(如果需要,将以下文件与现有VM IAM策略合并,请使用gcloud compute instances get-iam-policy进行检查):

gcloud compute instances set-iam-policy --zone=<INSTANCE1_ZONE> instance1 instance1_policy.yaml
gcloud compute instances set-iam-policy --zone=<INSTANCE2_ZONE> instance2 instance2_policy.yaml

Note also that IAM policies applying on your project can interfer with these policies. 另请注意,应用于您的项目的IAM策略可能会干扰这些策略。 For example, if user1@mydomain.com have roles/compute.admin role on the project, then he may also have access to instance2 , "ignoring" your policy on instance2 VM (he have inherited roles/compute.admin role from the project). 例如,如果user1@mydomain.com在项目上具有roles/compute.admin角色,那么他也可以访问instance2 ,“忽略”您在instance2 VM上的策略(他已经从项目继承了roles/compute.admin角色)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM