Skip to content

Commit

Permalink
Allow importing iam roles from a different project
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
Ty Larrabee authored and modular-magician committed Aug 27, 2019
1 parent 4447526 commit 220bb43
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions google-beta/resource_google_project_iam_custom_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package google

import (
"fmt"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down Expand Up @@ -107,13 +108,16 @@ func resourceGoogleProjectIamCustomRoleCreate(d *schema.ResourceData, meta inter
return resourceGoogleProjectIamCustomRoleRead(d, meta)
}

func extractProjectFromProjectIamCustomRoleID(id string) string {
parts := strings.Split(id, "/")

return parts[1]
}

func resourceGoogleProjectIamCustomRoleRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

project, err := getProject(d, config)
if err != nil {
return err
}
project := extractProjectFromProjectIamCustomRoleID(d.Id())

role, err := config.clientIAM.Projects.Roles.Get(d.Id()).Do()
if err != nil {
Expand Down

0 comments on commit 220bb43

Please sign in to comment.