Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure conditionally required identity fields are valid #1

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ func validateKubernetesCluster(d *schema.ResourceData, cluster *containerservice
}
}

// ensure conditionally-required identity values are valid
if v, exists := d.GetOk("identity"); exists {
rawIdentity := v.([]interface{})

if len(rawIdentity) != 0 {
identity := rawIdentity[0].(map[string]interface{})

if identityType := identity["type"].(string); identityType == string(containerservice.ResourceIdentityTypeUserAssigned) {
userAssignedIdentityId := identity["user_assigned_identity_id"].(string)

if userAssignedIdentityId == "" {
return fmt.Errorf("when `identity.type` is UserAssigned then `user_assigned_identity_id` must be set")
}
}
}
}

// @tombuildsstuff: As of 2020-03-30 it's no longer possible to create a cluster using a Service Principal
// for authentication (albeit this worked on 2020-03-27 via API version 2019-10-01 :shrug:). However it's
// possible to rotate the Service Principal for an existing Cluster - so this needs to be supported via
Expand Down