Class InstanceIAMMember


  • public class InstanceIAMMember
    extends com.pulumi.resources.CustomResource
    Three different resources help you manage your IAM policy for Compute Engine Instance. Each of these resources serves a different use case: * `gcp.compute.InstanceIAMPolicy`: Authoritative. Sets the IAM policy for the instance and replaces any existing policy already attached. * `gcp.compute.InstanceIAMBinding`: 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 instance are preserved. * `gcp.compute.InstanceIAMMember`: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the instance are preserved. A data source can be used to retrieve policy data in advent you do not need creation * `gcp.compute.InstanceIAMPolicy`: Retrieves the IAM policy for the instance > **Note:** `gcp.compute.InstanceIAMPolicy` **cannot** be used in conjunction with `gcp.compute.InstanceIAMBinding` and `gcp.compute.InstanceIAMMember` or they will fight over what your policy should be. > **Note:** `gcp.compute.InstanceIAMBinding` resources **can be** used in conjunction with `gcp.compute.InstanceIAMMember` resources **only if** they do not grant privilege to the same role. > **Note:** This resource supports IAM Conditions but they have some known limitations which can be found [here](https://cloud.google.com/iam/docs/conditions-overview#limitations). Please review this article if you are having issues with IAM Conditions. ## google\_compute\_instance\_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.compute.InstanceIAMPolicy; import com.pulumi.gcp.compute.InstanceIAMPolicyArgs; 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/compute.osLogin") .members("user:[email protected]") .build()) .build()); var policy = new InstanceIAMPolicy("policy", InstanceIAMPolicyArgs.builder() .project(google_compute_instance.default().project()) .zone(google_compute_instance.default().zone()) .instanceName(google_compute_instance.default().name()) .policyData(admin.applyValue(getIAMPolicyResult -> getIAMPolicyResult.policyData())) .build()); } } ``` With IAM Conditions: ```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.compute.InstanceIAMPolicy; import com.pulumi.gcp.compute.InstanceIAMPolicyArgs; 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/compute.osLogin") .members("user:[email protected]") .condition(GetIAMPolicyBindingConditionArgs.builder() .title("expires_after_2019_12_31") .description("Expiring at midnight of 2019-12-31") .expression("request.time < timestamp(\"2020-01-01T00:00:00Z\")") .build()) .build()) .build()); var policy = new InstanceIAMPolicy("policy", InstanceIAMPolicyArgs.builder() .project(google_compute_instance.default().project()) .zone(google_compute_instance.default().zone()) .instanceName(google_compute_instance.default().name()) .policyData(admin.applyValue(getIAMPolicyResult -> getIAMPolicyResult.policyData())) .build()); } } ``` ## google\_compute\_instance\_iam\_binding ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.compute.InstanceIAMBinding; import com.pulumi.gcp.compute.InstanceIAMBindingArgs; 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 InstanceIAMBinding("binding", InstanceIAMBindingArgs.builder() .project(google_compute_instance.default().project()) .zone(google_compute_instance.default().zone()) .instanceName(google_compute_instance.default().name()) .role("roles/compute.osLogin") .members("user:[email protected]") .build()); } } ``` With IAM Conditions: ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.compute.InstanceIAMBinding; import com.pulumi.gcp.compute.InstanceIAMBindingArgs; import com.pulumi.gcp.compute.inputs.InstanceIAMBindingConditionArgs; 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 InstanceIAMBinding("binding", InstanceIAMBindingArgs.builder() .project(google_compute_instance.default().project()) .zone(google_compute_instance.default().zone()) .instanceName(google_compute_instance.default().name()) .role("roles/compute.osLogin") .members("user:[email protected]") .condition(InstanceIAMBindingConditionArgs.builder() .title("expires_after_2019_12_31") .description("Expiring at midnight of 2019-12-31") .expression("request.time < timestamp(\"2020-01-01T00:00:00Z\")") .build()) .build()); } } ``` ## google\_compute\_instance\_iam\_member ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.compute.InstanceIAMMember; import com.pulumi.gcp.compute.InstanceIAMMemberArgs; 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 InstanceIAMMember("member", InstanceIAMMemberArgs.builder() .project(google_compute_instance.default().project()) .zone(google_compute_instance.default().zone()) .instanceName(google_compute_instance.default().name()) .role("roles/compute.osLogin") .member("user:[email protected]") .build()); } } ``` With IAM Conditions: ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.gcp.compute.InstanceIAMMember; import com.pulumi.gcp.compute.InstanceIAMMemberArgs; import com.pulumi.gcp.compute.inputs.InstanceIAMMemberConditionArgs; 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 InstanceIAMMember("member", InstanceIAMMemberArgs.builder() .project(google_compute_instance.default().project()) .zone(google_compute_instance.default().zone()) .instanceName(google_compute_instance.default().name()) .role("roles/compute.osLogin") .member("user:[email protected]") .condition(InstanceIAMMemberConditionArgs.builder() .title("expires_after_2019_12_31") .description("Expiring at midnight of 2019-12-31") .expression("request.time < timestamp(\"2020-01-01T00:00:00Z\")") .build()) .build()); } } ``` ## Import For all import syntaxes, the "resource in question" can take any of the following forms* projects/{{project}}/zones/{{zone}}/instances/{{name}} * {{project}}/{{zone}}/{{name}} * {{zone}}/{{name}} * {{name}} Any variables not passed in the import command will be taken from the provider configuration. Compute Engine instance 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:compute/instanceIAMMember:InstanceIAMMember editor "projects/{{project}}/zones/{{zone}}/instances/{{instance}} roles/compute.osLogin user:[email protected]" ``` IAM binding imports use space-delimited identifiersthe resource in question and the role, e.g. ```sh $ pulumi import gcp:compute/instanceIAMMember:InstanceIAMMember editor "projects/{{project}}/zones/{{zone}}/instances/{{instance}} roles/compute.osLogin" ``` IAM policy imports use the identifier of the resource in question, e.g. ```sh $ pulumi import gcp:compute/instanceIAMMember:InstanceIAMMember editor projects/{{project}}/zones/{{zone}}/instances/{{instance}} ``` -> **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`.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<InstanceIAMMemberCondition>> condition()  
      com.pulumi.core.Output<java.lang.String> etag()  
      static InstanceIAMMember get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, InstanceIAMMemberState 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> instanceName()  
      com.pulumi.core.Output<java.lang.String> member()  
      com.pulumi.core.Output<java.lang.String> project()  
      com.pulumi.core.Output<java.lang.String> role()  
      com.pulumi.core.Output<java.lang.String> zone()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InstanceIAMMember

        public InstanceIAMMember​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • InstanceIAMMember

        public InstanceIAMMember​(java.lang.String name,
                                 InstanceIAMMemberArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • InstanceIAMMember

        public InstanceIAMMember​(java.lang.String name,
                                 InstanceIAMMemberArgs 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

      • condition

        public com.pulumi.core.Output<java.util.Optional<InstanceIAMMemberCondition>> condition()
        Returns:
        An [IAM Condition](https://cloud.google.com/iam/docs/conditions-overview) for a given binding. Structure is documented below.
      • etag

        public com.pulumi.core.Output<java.lang.String> etag()
        Returns:
        (Computed) The etag of the IAM policy.
      • instanceName

        public com.pulumi.core.Output<java.lang.String> instanceName()
        Returns:
        Used to find the parent resource to bind the IAM policy to
      • member

        public com.pulumi.core.Output<java.lang.String> member()
      • project

        public com.pulumi.core.Output<java.lang.String> project()
        Returns:
        The ID of the project in which the resource belongs. If it is not provided, the project will be parsed from the identifier of the parent resource. If no project is provided in the parent identifier and no project is specified, the provider project is used. * `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"
      • role

        public com.pulumi.core.Output<java.lang.String> role()
        Returns:
        The role that should be applied. Only one `gcp.compute.InstanceIAMBinding` can be used per role. Note that custom roles must be of the format `[projects|organizations]/{parent-name}/roles/{role-name}`.
      • zone

        public com.pulumi.core.Output<java.lang.String> zone()
        Returns:
        A reference to the zone where the machine resides. Used to find the parent resource to bind the IAM policy to. If not specified, the value will be parsed from the identifier of the parent resource. If no zone is provided in the parent identifier and no zone is specified, it is taken from the provider configuration.
      • get

        public static InstanceIAMMember get​(java.lang.String name,
                                            com.pulumi.core.Output<java.lang.String> id,
                                            @Nullable
                                            InstanceIAMMemberState 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.