Merge pull request #9714 from hashicorp/fix_9688

provide more helpful error message than the one returned by the clien…
This commit is contained in:
Megan Marsh 2020-08-06 10:54:21 -07:00 committed by GitHub
commit 04d7a10aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -103,7 +103,8 @@ type Config struct {
// Authentication via OAUTH
ClientConfig client.Config `mapstructure:",squash"`
// If set with one or more resource ids of user assigned managed identities, they will be configured on the VM.
// A list of one or more fully-qualified resource IDs of user assigned
// managed identities to be configured on the VM.
// See [documentation](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token)
// for how to acquire tokens within the VM.
// To assign a user assigned managed identity to a VM, the provided account or service principal must have [Managed Identity Operator](https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#managed-identity-operator)
@ -787,6 +788,10 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) {
for _, rid := range c.UserAssignedManagedIdentities {
r, err := client.ParseResourceID(rid)
if err != nil {
err := fmt.Errorf("Error parsing resource ID from `user_assigned_managed_identities`; please make sure"+
" that this value follows the full resource id format: "+
"/subscriptions/<SUBSCRIPTON_ID>/resourcegroups/<RESOURCE_GROUP>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<USER_ASSIGNED_IDENTITY_NAME>.\n"+
" Original error: %s", err)
errs = packer.MultiErrorAppend(errs, err)
} else {
if !strings.EqualFold(r.Provider, "Microsoft.ManagedIdentity") {

View File

@ -1,6 +1,7 @@
<!-- Code generated from the comments of the Config struct in builder/azure/arm/config.go; DO NOT EDIT MANUALLY -->
- `user_assigned_managed_identities` ([]string) - If set with one or more resource ids of user assigned managed identities, they will be configured on the VM.
- `user_assigned_managed_identities` ([]string) - A list of one or more fully-qualified resource IDs of user assigned
managed identities to be configured on the VM.
See [documentation](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token)
for how to acquire tokens within the VM.
To assign a user assigned managed identity to a VM, the provided account or service principal must have [Managed Identity Operator](https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#managed-identity-operator)