Skip to content
Permalink
Browse files

Add system_assigned_identity and user_assigned_identity config parame…

…ters, add systemAssignedIdentity and userAssignedIdentities parameters to ARM templates
  • Loading branch information...
zanecodes committed Dec 21, 2018
1 parent 9ac4270 commit 22bc172e415ec07c25f9461d9047513359c61866
Showing with 48 additions and 0 deletions.
  1. +10 −0 lib/kitchen/driver/azurerm.rb
  2. +19 −0 templates/internal.erb
  3. +19 −0 templates/public.erb
@@ -146,6 +146,14 @@ class Azurerm < Kitchen::Driver::Base
false
end

default_config(:system_assigned_identity) do |_config|
false
end

default_config(:user_assigned_identities) do |_config|
[]
end

default_config(:destroy_explicit_resource_group) do |_config|
true
end
@@ -166,6 +174,8 @@ def create(state)
adminPassword: state[:password] || "P2ssw0rd",
dnsNameForPublicIP: "kitchen-#{state[:uuid]}",
vmName: state[:vm_name],
systemAssignedIdentity: config[:system_assigned_identity],
userAssignedIdentities: config[:user_assigned_identities],
}

if config[:subscription_id].to_s == ""
@@ -143,6 +143,20 @@
"description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
}
},
"systemAssignedIdentity": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Whether to enable system assigned identity for the vm."
}
},
"userAssignedIdentities": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "A list of resource IDs for user identities to associate with the Virtual Machine, or empty to disable user assigned identities."
}
},
"bootDiagnosticsEnabled": {
"type": "string",
"defaultValue": "true",
@@ -164,6 +178,7 @@
"vmStorageAccountContainerName": "vhds",
"vmName": "[parameters('vmName')]",
"vmSize": "[parameters('vmSize')]",
"vmIdentityType": "[if(parameters('systemAssignedIdentity'), if(empty(parameters('userAssignedIdentities')), 'SystemAssigned', 'SystemAssigned, UserAssigned'), if(empty(parameters('userAssignedIdentities')), 'None', 'UserAssigned'))]",
"virtualNetworkName": "vnet",
"vnetID": "<%= vnet_id %>",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
@@ -342,6 +357,10 @@
<%- end -%>
}
},
"identity": {
"type": "[variables('vmIdentityType')]",
"identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
},
"tags": {
<%= vm_tags unless vm_tags.empty? %>
}
@@ -143,6 +143,20 @@
"description": "The type of storage to use (e.g. Standard_LRS or Premium_LRS)."
}
},
"systemAssignedIdentity": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Whether to enable system assigned identity for the vm."
}
},
"userAssignedIdentities": {
"type": "array",
"defaultValue": [],
"metadata": {
"description": "A list of resource IDs for user identities to associate with the Virtual Machine, or empty to disable user assigned identities."
}
},
"bootDiagnosticsEnabled": {
"type": "string",
"defaultValue": "true",
@@ -164,6 +178,7 @@
"vmStorageAccountContainerName": "vhds",
"vmName": "[parameters('vmName')]",
"vmSize": "[parameters('vmSize')]",
"vmIdentityType": "[if(parameters('systemAssignedIdentity'), if(empty(parameters('userAssignedIdentities')), 'SystemAssigned', 'SystemAssigned, UserAssigned'), if(empty(parameters('userAssignedIdentities')), 'None', 'UserAssigned'))]",
"virtualNetworkName": "vnet",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]"
@@ -360,6 +375,10 @@
<%- end -%>
}
},
"identity": {
"type": "[variables('vmIdentityType')]",
"identityIds": "[if(empty(parameters('userAssignedIdentities')), json('null'), parameters('userAssignedIdentities'))]"
},
"tags": {
<%= vm_tags unless vm_tags.empty? %>
}

0 comments on commit 22bc172

Please sign in to comment.
You can’t perform that action at this time.