Class GroupPolicy


  • public class GroupPolicy
    extends com.pulumi.resources.CustomResource
    Provides an IAM policy attached to a group. > **NOTE:** We suggest using explicit JSON encoding or `aws.iam.getPolicyDocument` when assigning a value to `policy`. They seamlessly translate configuration to JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.iam.Group;
     import com.pulumi.aws.iam.GroupArgs;
     import com.pulumi.aws.iam.GroupPolicy;
     import com.pulumi.aws.iam.GroupPolicyArgs;
     import static com.pulumi.codegen.internal.Serialization.*;
     import java.util.ArrayList;
     import java.util.Arrays;
     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 myDevelopers = new Group("myDevelopers", GroupArgs.builder()
                 .name("developers")
                 .path("/users/")
                 .build());
     
             var myDeveloperPolicy = new GroupPolicy("myDeveloperPolicy", GroupPolicyArgs.builder()
                 .name("my_developer_policy")
                 .group(myDevelopers.name())
                 .policy(serializeJson(
                     jsonObject(
                         jsonProperty("Version", "2012-10-17"),
                         jsonProperty("Statement", jsonArray(jsonObject(
                             jsonProperty("Action", jsonArray("ec2:Describe*")),
                             jsonProperty("Effect", "Allow"),
                             jsonProperty("Resource", "*")
                         )))
                     )))
                 .build());
     
         }
     }
     
     
    ## Import Using `pulumi import`, import IAM Group Policies using the `group_name:group_policy_name`. For example: ```sh $ pulumi import aws:iam/groupPolicy:GroupPolicy mypolicy group_of_mypolicy_name:mypolicy_name ```
    • 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
      static GroupPolicy get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, GroupPolicyState 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> group()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.String> namePrefix()  
      com.pulumi.core.Output<java.lang.String> policy()  
      • 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

      • GroupPolicy

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

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

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

      • group

        public com.pulumi.core.Output<java.lang.String> group()
        Returns:
        The IAM group to attach to the policy.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        The name of the policy. If omitted, the provider will assign a random, unique name.
      • namePrefix

        public com.pulumi.core.Output<java.lang.String> namePrefix()
        Returns:
        Creates a unique name beginning with the specified prefix. Conflicts with `name`.
      • policy

        public com.pulumi.core.Output<java.lang.String> policy()
        Returns:
        The policy document. This is a JSON formatted string.
      • get

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