Runtime Iam Binding Args
Three different resources help you manage your IAM policy for Cloud AI Notebooks Runtime. Each of these resources serves a different use case:
gcp.notebooks.RuntimeIamPolicy
: Authoritative. Sets the IAM policy for the runtime and replaces any existing policy already attached.gcp.notebooks.RuntimeIamBinding
: Authoritative for a given role. Updates the IAM policy to grant a role to a list of members. Other roles within the IAM policy for the runtime are preserved.gcp.notebooks.RuntimeIamMember
: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the runtime are preserved. A data source can be used to retrieve policy data in advent you do not need creationgcp.notebooks.RuntimeIamPolicy
: Retrieves the IAM policy for the runtime
Note:
gcp.notebooks.RuntimeIamPolicy
cannot be used in conjunction withgcp.notebooks.RuntimeIamBinding
andgcp.notebooks.RuntimeIamMember
or they will fight over what your policy should be. Note:gcp.notebooks.RuntimeIamBinding
resources can be used in conjunction withgcp.notebooks.RuntimeIamMember
resources only if they do not grant privilege to the same role.
google\_notebooks\_runtime\_iam\_policy
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const admin = gcp.organizations.getIAMPolicy({
bindings: [{
role: "roles/viewer",
members: ["user:jane@example.com"],
}],
});
const policy = new gcp.notebooks.RuntimeIamPolicy("policy", {
project: google_notebooks_runtime.runtime.project,
location: google_notebooks_runtime.runtime.location,
runtimeName: google_notebooks_runtime.runtime.name,
policyData: admin.then(admin => admin.policyData),
});
import pulumi
import pulumi_gcp as gcp
admin = gcp.organizations.get_iam_policy(bindings=[gcp.organizations.GetIAMPolicyBindingArgs(
role="roles/viewer",
members=["user:jane@example.com"],
)])
policy = gcp.notebooks.RuntimeIamPolicy("policy",
project=google_notebooks_runtime["runtime"]["project"],
location=google_notebooks_runtime["runtime"]["location"],
runtime_name=google_notebooks_runtime["runtime"]["name"],
policy_data=admin.policy_data)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var admin = Gcp.Organizations.GetIAMPolicy.Invoke(new()
{
Bindings = new[]
{
new Gcp.Organizations.Inputs.GetIAMPolicyBindingInputArgs
{
Role = "roles/viewer",
Members = new[]
{
"user:jane@example.com",
},
},
},
});
var policy = new Gcp.Notebooks.RuntimeIamPolicy("policy", new()
{
Project = google_notebooks_runtime.Runtime.Project,
Location = google_notebooks_runtime.Runtime.Location,
RuntimeName = google_notebooks_runtime.Runtime.Name,
PolicyData = admin.Apply(getIAMPolicyResult => getIAMPolicyResult.PolicyData),
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/notebooks"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
admin, err := organizations.LookupIAMPolicy(ctx, &organizations.LookupIAMPolicyArgs{
Bindings: []organizations.GetIAMPolicyBinding{
{
Role: "roles/viewer",
Members: []string{
"user:jane@example.com",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = notebooks.NewRuntimeIamPolicy(ctx, "policy", ¬ebooks.RuntimeIamPolicyArgs{
Project: pulumi.Any(google_notebooks_runtime.Runtime.Project),
Location: pulumi.Any(google_notebooks_runtime.Runtime.Location),
RuntimeName: pulumi.Any(google_notebooks_runtime.Runtime.Name),
PolicyData: *pulumi.String(admin.PolicyData),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetIAMPolicyArgs;
import com.pulumi.gcp.notebooks.RuntimeIamPolicy;
import com.pulumi.gcp.notebooks.RuntimeIamPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var admin = OrganizationsFunctions.getIAMPolicy(GetIAMPolicyArgs.builder()
.bindings(GetIAMPolicyBindingArgs.builder()
.role("roles/viewer")
.members("user:jane@example.com")
.build())
.build());
var policy = new RuntimeIamPolicy("policy", RuntimeIamPolicyArgs.builder()
.project(google_notebooks_runtime.runtime().project())
.location(google_notebooks_runtime.runtime().location())
.runtimeName(google_notebooks_runtime.runtime().name())
.policyData(admin.applyValue(getIAMPolicyResult -> getIAMPolicyResult.policyData()))
.build());
}
}
resources:
policy:
type: gcp:notebooks:RuntimeIamPolicy
properties:
project: ${google_notebooks_runtime.runtime.project}
location: ${google_notebooks_runtime.runtime.location}
runtimeName: ${google_notebooks_runtime.runtime.name}
policyData: ${admin.policyData}
variables:
admin:
fn::invoke:
Function: gcp:organizations:getIAMPolicy
Arguments:
bindings:
- role: roles/viewer
members:
- user:jane@example.com
google\_notebooks\_runtime\_iam\_binding
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const binding = new gcp.notebooks.RuntimeIamBinding("binding", {
project: google_notebooks_runtime.runtime.project,
location: google_notebooks_runtime.runtime.location,
runtimeName: google_notebooks_runtime.runtime.name,
role: "roles/viewer",
members: ["user:jane@example.com"],
});
import pulumi
import pulumi_gcp as gcp
binding = gcp.notebooks.RuntimeIamBinding("binding",
project=google_notebooks_runtime["runtime"]["project"],
location=google_notebooks_runtime["runtime"]["location"],
runtime_name=google_notebooks_runtime["runtime"]["name"],
role="roles/viewer",
members=["user:jane@example.com"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var binding = new Gcp.Notebooks.RuntimeIamBinding("binding", new()
{
Project = google_notebooks_runtime.Runtime.Project,
Location = google_notebooks_runtime.Runtime.Location,
RuntimeName = google_notebooks_runtime.Runtime.Name,
Role = "roles/viewer",
Members = new[]
{
"user:jane@example.com",
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/notebooks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := notebooks.NewRuntimeIamBinding(ctx, "binding", ¬ebooks.RuntimeIamBindingArgs{
Project: pulumi.Any(google_notebooks_runtime.Runtime.Project),
Location: pulumi.Any(google_notebooks_runtime.Runtime.Location),
RuntimeName: pulumi.Any(google_notebooks_runtime.Runtime.Name),
Role: pulumi.String("roles/viewer"),
Members: pulumi.StringArray{
pulumi.String("user:jane@example.com"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.notebooks.RuntimeIamBinding;
import com.pulumi.gcp.notebooks.RuntimeIamBindingArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var binding = new RuntimeIamBinding("binding", RuntimeIamBindingArgs.builder()
.project(google_notebooks_runtime.runtime().project())
.location(google_notebooks_runtime.runtime().location())
.runtimeName(google_notebooks_runtime.runtime().name())
.role("roles/viewer")
.members("user:jane@example.com")
.build());
}
}
resources:
binding:
type: gcp:notebooks:RuntimeIamBinding
properties:
project: ${google_notebooks_runtime.runtime.project}
location: ${google_notebooks_runtime.runtime.location}
runtimeName: ${google_notebooks_runtime.runtime.name}
role: roles/viewer
members:
- user:jane@example.com
google\_notebooks\_runtime\_iam\_member
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const member = new gcp.notebooks.RuntimeIamMember("member", {
project: google_notebooks_runtime.runtime.project,
location: google_notebooks_runtime.runtime.location,
runtimeName: google_notebooks_runtime.runtime.name,
role: "roles/viewer",
member: "user:jane@example.com",
});
import pulumi
import pulumi_gcp as gcp
member = gcp.notebooks.RuntimeIamMember("member",
project=google_notebooks_runtime["runtime"]["project"],
location=google_notebooks_runtime["runtime"]["location"],
runtime_name=google_notebooks_runtime["runtime"]["name"],
role="roles/viewer",
member="user:jane@example.com")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var member = new Gcp.Notebooks.RuntimeIamMember("member", new()
{
Project = google_notebooks_runtime.Runtime.Project,
Location = google_notebooks_runtime.Runtime.Location,
RuntimeName = google_notebooks_runtime.Runtime.Name,
Role = "roles/viewer",
Member = "user:jane@example.com",
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/notebooks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := notebooks.NewRuntimeIamMember(ctx, "member", ¬ebooks.RuntimeIamMemberArgs{
Project: pulumi.Any(google_notebooks_runtime.Runtime.Project),
Location: pulumi.Any(google_notebooks_runtime.Runtime.Location),
RuntimeName: pulumi.Any(google_notebooks_runtime.Runtime.Name),
Role: pulumi.String("roles/viewer"),
Member: pulumi.String("user:jane@example.com"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.notebooks.RuntimeIamMember;
import com.pulumi.gcp.notebooks.RuntimeIamMemberArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var member = new RuntimeIamMember("member", RuntimeIamMemberArgs.builder()
.project(google_notebooks_runtime.runtime().project())
.location(google_notebooks_runtime.runtime().location())
.runtimeName(google_notebooks_runtime.runtime().name())
.role("roles/viewer")
.member("user:jane@example.com")
.build());
}
}
resources:
member:
type: gcp:notebooks:RuntimeIamMember
properties:
project: ${google_notebooks_runtime.runtime.project}
location: ${google_notebooks_runtime.runtime.location}
runtimeName: ${google_notebooks_runtime.runtime.name}
role: roles/viewer
member: user:jane@example.com
Import
For all import syntaxes, the "resource in question" can take any of the following forms* projects/{{project}}/locations/{{location}}/runtimes/{{runtime_name}} * {{project}}/{{location}}/{{runtime_name}} * {{location}}/{{runtime_name}} * {{runtime_name}} Any variables not passed in the import command will be taken from the provider configuration. Cloud AI Notebooks runtime IAM resources can be imported using the resource identifiers, role, and member. IAM member imports use space-delimited identifiersthe resource in question, the role, and the member identity, e.g.
$ pulumi import gcp:notebooks/runtimeIamBinding:RuntimeIamBinding editor "projects/{{project}}/locations/{{location}}/runtimes/{{runtime_name}} roles/viewer user:jane@example.com"
IAM binding imports use space-delimited identifiersthe resource in question and the role, e.g.
$ pulumi import gcp:notebooks/runtimeIamBinding:RuntimeIamBinding editor "projects/{{project}}/locations/{{location}}/runtimes/{{runtime_name}} roles/viewer"
IAM policy imports use the identifier of the resource in question, e.g.
$ pulumi import gcp:notebooks/runtimeIamBinding:RuntimeIamBinding editor projects/{{project}}/locations/{{location}}/runtimes/{{runtime_name}}
->Custom RolesIf you're importing a IAM resource with a custom role, make sure to use the full name of the custom role, e.g. [projects/my-project|organizations/my-org]/roles/my-custom-role
.