我正在尝试根据此处1中给出的示例创建简单的 VM 。我想将自定义服务帐户2添加到此 VM。我的配置看起来像这样
def GenerateConfig(context):
"""Create instance with disks."""
resources = [{
'type': 'compute.v1.instance',
'name': 'vm-' + context.env['deployment'],
'properties': {
'zone': context.properties['zone'],
'disks': [{
'deviceName': 'boot',
'type': 'PERSISTENT',
'boot': True,
'autoDelete': True,
'initializeParams': {
'diskName': 'disk-' + context.env['deployment'],
}
}],
'networkInterfaces': [{
'network': '...',
'subnetwork': '...',
'no-address': True,
}],
'tags':{
'items': [context.env['deployment']]
},
'service-account': ''.join(['custom-compute@',
context.env['project'],
'.iam.gserviceaccount.com']),
'scopes': ['https://www.googleapis.com/auth/devstorage.read_only',
'https://www.googleapis.com/auth/logging.write',
'https://www.googleapis.com/auth/monitoring.write',
'https://www.googleapis.com/auth/trace.append']
}
}]
return {'resources': resources}
我能够成功创建部署。但是,当我描述新创建的实例时,它没有任何与 vm 关联的“服务帐户”。
我找不到任何将服务帐户添加到部署管理器模板的示例。我也尝试使用“serviceAccount”键而不是“service-account”,但没有任何成功。有谁知道我错过了什么?