Package com.pulumi.gcp.servicedirectory
Class NamespaceIamPolicy
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.gcp.servicedirectory.NamespaceIamPolicy
-
public class NamespaceIamPolicy extends com.pulumi.resources.CustomResource
Three different resources help you manage your IAM policy for Service Directory Namespace. Each of these resources serves a different use case: * `gcp.servicedirectory.NamespaceIamPolicy`: Authoritative. Sets the IAM policy for the namespace and replaces any existing policy already attached. * `gcp.servicedirectory.NamespaceIamBinding`: 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 namespace are preserved. * `gcp.servicedirectory.NamespaceIamMember`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the namespace are preserved. A data source can be used to retrieve policy data in advent you do not need creation * `gcp.servicedirectory.NamespaceIamPolicy`: Retrieves the IAM policy for the namespace > **Note:** `gcp.servicedirectory.NamespaceIamPolicy` **cannot** be used in conjunction with `gcp.servicedirectory.NamespaceIamBinding` and `gcp.servicedirectory.NamespaceIamMember` or they will fight over what your policy should be. > **Note:** `gcp.servicedirectory.NamespaceIamBinding` resources **can be** used in conjunction with `gcp.servicedirectory.NamespaceIamMember` resources **only if** they do not grant privilege to the same role. ## google\_service\_directory\_namespace\_iam\_policy ```java 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.servicedirectory.NamespaceIamPolicy; import com.pulumi.gcp.servicedirectory.NamespaceIamPolicyArgs; import com.pulumi.resources.CustomResourceOptions; 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:[email protected]") .build()) .build()); var policy = new NamespaceIamPolicy("policy", NamespaceIamPolicyArgs.builder() .policyData(admin.applyValue(getIAMPolicyResult -> getIAMPolicyResult.policyData())) .build(), CustomResourceOptions.builder() .provider(google_beta) .build()); } } ``` ## google\_service\_directory\_namespace\_iam\_binding ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.servicedirectory.NamespaceIamBinding; import com.pulumi.gcp.servicedirectory.NamespaceIamBindingArgs; import com.pulumi.resources.CustomResourceOptions; 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 NamespaceIamBinding("binding", NamespaceIamBindingArgs.builder() .role("roles/viewer") .members("user:[email protected]") .build(), CustomResourceOptions.builder() .provider(google_beta) .build()); } } ``` ## google\_service\_directory\_namespace\_iam\_member ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.servicedirectory.NamespaceIamMember; import com.pulumi.gcp.servicedirectory.NamespaceIamMemberArgs; import com.pulumi.resources.CustomResourceOptions; 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 NamespaceIamMember("member", NamespaceIamMemberArgs.builder() .role("roles/viewer") .member("user:[email protected]") .build(), CustomResourceOptions.builder() .provider(google_beta) .build()); } } ``` ## Import For all import syntaxes, the "resource in question" can take any of the following forms* projects/{{project}}/locations/{{location}}/namespaces/{{namespace_id}} * {{project}}/{{location}}/{{namespace_id}} * {{location}}/{{namespace_id}} Any variables not passed in the import command will be taken from the provider configuration. Service Directory namespace 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. ```sh $ pulumi import gcp:servicedirectory/namespaceIamPolicy:NamespaceIamPolicy editor "projects/{{project}}/locations/{{location}}/namespaces/{{namespace_id}} roles/viewer user:[email protected]" ``` IAM binding imports use space-delimited identifiersthe resource in question and the role, e.g. ```sh $ pulumi import gcp:servicedirectory/namespaceIamPolicy:NamespaceIamPolicy editor "projects/{{project}}/locations/{{location}}/namespaces/{{namespace_id}} roles/viewer" ``` IAM policy imports use the identifier of the resource in question, e.g. ```sh $ pulumi import gcp:servicedirectory/namespaceIamPolicy:NamespaceIamPolicy editor projects/{{project}}/locations/{{location}}/namespaces/{{namespace_id}} ``` -> **Custom Roles**If 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`.
-
-
Constructor Summary
Constructors Constructor Description NamespaceIamPolicy(java.lang.String name)
NamespaceIamPolicy(java.lang.String name, NamespaceIamPolicyArgs args)
NamespaceIamPolicy(java.lang.String name, NamespaceIamPolicyArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>
etag()
static NamespaceIamPolicy
get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, NamespaceIamPolicyState state, com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>
name()
com.pulumi.core.Output<java.lang.String>
policyData()
-
-
-
Constructor Detail
-
NamespaceIamPolicy
public NamespaceIamPolicy(java.lang.String name)
- Parameters:
name
- The _unique_ name of the resulting resource.
-
NamespaceIamPolicy
public NamespaceIamPolicy(java.lang.String name, NamespaceIamPolicyArgs args)
- Parameters:
name
- The _unique_ name of the resulting resource.args
- The arguments to use to populate this resource's properties.
-
NamespaceIamPolicy
public NamespaceIamPolicy(java.lang.String name, NamespaceIamPolicyArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)
- Parameters:
name
- The _unique_ name of the resulting resource.args
- The arguments to use to populate this resource's properties.options
- A bag of options that control this resource's behavior.
-
-
Method Detail
-
etag
public com.pulumi.core.Output<java.lang.String> etag()
- Returns:
- (Computed) The etag of the IAM policy.
-
name
public com.pulumi.core.Output<java.lang.String> name()
- Returns:
- Used to find the parent resource to bind the IAM policy to * `member/members` - (Required) Identities that will be granted the privilege in `role`. Each entry can have one of the following values: * **allUsers**: A special identifier that represents anyone who is on the internet; with or without a Google account. * **allAuthenticatedUsers**: A special identifier that represents anyone who is authenticated with a Google account or a service account. * **user:{emailid}**: An email address that represents a specific Google account. For example, [email protected] or [email protected]. * **serviceAccount:{emailid}**: An email address that represents a service account. For example, [email protected]. * **group:{emailid}**: An email address that represents a Google group. For example, [email protected]. * **domain:{domain}**: A G Suite domain (primary, instead of alias) name that represents all the users of that domain. For example, google.com or example.com. * **projectOwner:projectid**: Owners of the given project. For example, "projectOwner:my-example-project" * **projectEditor:projectid**: Editors of the given project. For example, "projectEditor:my-example-project" * **projectViewer:projectid**: Viewers of the given project. For example, "projectViewer:my-example-project"
-
policyData
public com.pulumi.core.Output<java.lang.String> policyData()
- Returns:
- The policy data generated by a `gcp.organizations.getIAMPolicy` data source.
-
get
public static NamespaceIamPolicy get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable NamespaceIamPolicyState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name
- The _unique_ name of the resulting resource.id
- The _unique_ provider ID of the resource to lookup.state
-options
- Optional settings to control the behavior of the CustomResource.
-
-