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 26, 2019
1 parent 8f0d10a commit 0e4f5ac
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 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,17 @@ func resourceGoogleProjectIamCustomRoleCreate(d *schema.ResourceData, meta inter
return resourceGoogleProjectIamCustomRoleRead(d, meta)
}

func extractProjectFromProjectIamCustomRoleID(id string) string {
//bucket, NotificationID
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 0e4f5ac

Please sign in to comment.