一个管理身份感知代理策略的工具google云平台

google-iap的Python项目详细描述


允许通过身份感知代理连接到多个条件下的实例

安装:

  pip install google-iap   

先决条件:

The service account used must have at least the roles Compute Viewer and IAP Policy Admin
You must authorize the Identity-Aware Proxy network (35.235.240.0/20) on port 22 as input to the desired network at the firewall

使用示例:

  google-iap iap get --credentials=service-account.json --project=<projectId>     

  google-iap iap get --credentials=service-account.json --project=<projectId> --zone=<zone>     

  google-iap iap get --credentials=service-account.json --project=<projectId> --zone=<zone> --instance=<instance>    

  google-iap iap get --credentials=service-account.json --project=<projectId> --zone=<zone> --instance=<instance> --format=yaml    

  google-iap iap get --credentials=service-account.json --project=<projectId> --zone=<zone> --instance=<instance> --format=json    

  google-iap iap set --credentials=service-account.json --project=<projectId> --policy=POLICY_FILE.json    

  google-iap iap set --credentials=service-account.json --project=<projectId> --policy=POLICY_FILE.yaml   

  google-iap iap set --credentials=service-account.json --project=<projectId> --zone=<zone> --policy=POLICY_FILE.yaml    

  google-iap iap set --credentials=service-account.json --project=<projectId> --zone=<zone> --instance=<instance> --policy=POLICY_FILE.yaml    

文件示例policy_file.yaml:

---
policy:
  bindings:
  - role: roles/iap.tunnelResourceAccessor
    members:
    - user:account@gmail.com
    condition:
      title: adm-ssh
      expression: "resource.name.startsWith(\"instance-name\") && resource.type == \"google.cloud.compute.Instance\" && destination.port == 22"

文件示例policy_file.json:

{

  "policy": {

    "bindings": [

      {

        "role": "roles/iap.tunnelResourceAccessor",

        "members": ["user:account@gmail.com"],

        "condition": {

           "title": "adm-ssh",

           "expression": "resource.name.startsWith(\"instance-name\") && resource.type == \"google.cloud.compute.Instance\" && destination.port == 22"

        }

      }

    ]

  }

}

您可以显示cel表达式->;https://cloud.google.com/iam/docs/conditions-overview?hl=ko#example_destination_ipport_expressions_for_cloud_iap_for_tcp_tunneling

使用:

  • ssh隧道:
    gcloud beta compute start-iap-tunnel <instance> 80 --local-host-port=localhost:8888 --network-interface=nic0 --zone=<zone>    
    
  • ssh连接:
    gcloud beta compute ssh <instance> --tunnel-through-iap --zone=<zone>    
    

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
我可以用C++代码使用java代码吗?   java使用JSR303在派生类中提供更具体的约束   java在这个查找唯一路径数算法中我做错了什么?   java如何为2个不同的服务提供商使用2个不同的SSL证书?   java在Gridview上绘制文本   java使用连接for循环构建字符串名   java StringBuilder拆分无法处理某些文件   java事件关注EditText   Java Web Start“找不到URL的缓存资源”   java程序从命令行运行的速度比在Eclipse中慢   java为什么HttpServletRequest会截断#字符上的url输入?   java自定义折叠工具栏平滑标题大小调整   使用Mockito对安卓 java中调用另一个静态函数的函数进行单元测试   http在java客户机中使用cachecontrol头   java如何使用。是否使用Delimiter从输入文件中排除标点符号和数字?   使用上下文作为参数/参数的java   java更有效地从Jar中提取文件   java为多个JButton提供相同的actionListener