在使用Google Deployment Manager添加IAM条件访问时,您需要了解以下几个基础概念:
以下是一个使用YAML配置文件在Deployment Manager中添加IAM条件访问的示例:
resources:
- name: my-resource
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: zones/us-central1-a/machineTypes/n1-standard-1
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: projects/debian-cloud/global/images/family/debian-10
networkInterfaces:
- network: global/networks/default
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
metadata:
dependsOn:
- my-network
accessControl:
gcpIamPolicy:
bindings:
- role: roles/compute.instanceAdmin
members:
- user:test@example.com
condition:
title: "Allow access only during working hours"
expression: 'request.time < timestamp("17:00") && request.time > timestamp("09:00")'
accessControl
部分,并定义IAM策略。condition
字段定义访问条件。通过以上步骤,您可以在Google Deployment Manager中成功添加IAM条件访问。
领取专属 10元无门槛券
手把手带您无忧上云