set identity field in the template
This commit is contained in:
parent
d9c9bfbae8
commit
7c1a62dfed
|
@ -61,6 +61,10 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error)
|
|||
builder.BuildWindows(config.tmpKeyVaultName, config.tmpWinRMCertificateUrl)
|
||||
}
|
||||
|
||||
if len(config.UserAssignedManagedIdentities) != 0 {
|
||||
builder.SetIdentity(config.UserAssignedManagedIdentities)
|
||||
}
|
||||
|
||||
if config.ImageUrl != "" {
|
||||
builder.SetImageUrl(config.ImageUrl, osType, config.diskCachingType)
|
||||
} else if config.CustomManagedImageName != "" {
|
||||
|
|
|
@ -103,6 +103,28 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string)
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *TemplateBuilder) SetIdentity(userAssignedManagedIdentities []string) error {
|
||||
resource, err := s.getResourceByType(resourceVirtualMachine)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var id *Identity
|
||||
|
||||
if len(userAssignedManagedIdentities) != 0 {
|
||||
id = &Identity{
|
||||
Type: to.StringPtr("UserAssigned"),
|
||||
UserAssignedIdentities: make(map[string]*UserAssignedIdentitiesValue),
|
||||
}
|
||||
for _, uid := range userAssignedManagedIdentities {
|
||||
id.UserAssignedIdentities[uid] = &UserAssignedIdentitiesValue{}
|
||||
}
|
||||
}
|
||||
|
||||
resource.Identity = id
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *TemplateBuilder) SetManagedDiskUrl(managedImageId string, storageAccountType compute.StorageAccountTypes, cachingType compute.CachingTypes) error {
|
||||
resource, err := s.getResourceByType(resourceVirtualMachine)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue