1. Packages
  2. AWS Classic
  3. API Docs
  4. iam
  5. GroupPolicy

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

aws.iam.GroupPolicy

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

    Provides an IAM policy attached to a group.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var myDevelopers = new Aws.Iam.Group("myDevelopers", new()
        {
            Path = "/users/",
        });
    
        var myDeveloperPolicy = new Aws.Iam.GroupPolicy("myDeveloperPolicy", new()
        {
            Group = myDevelopers.Name,
            Policy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Version"] = "2012-10-17",
                ["Statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["Action"] = new[]
                        {
                            "ec2:Describe*",
                        },
                        ["Effect"] = "Allow",
                        ["Resource"] = "*",
                    },
                },
            }),
        });
    
    });
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		myDevelopers, err := iam.NewGroup(ctx, "myDevelopers", &iam.GroupArgs{
    			Path: pulumi.String("/users/"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Version": "2012-10-17",
    			"Statement": []map[string]interface{}{
    				map[string]interface{}{
    					"Action": []string{
    						"ec2:Describe*",
    					},
    					"Effect":   "Allow",
    					"Resource": "*",
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		_, err = iam.NewGroupPolicy(ctx, "myDeveloperPolicy", &iam.GroupPolicyArgs{
    			Group:  myDevelopers.Name,
    			Policy: pulumi.String(json0),
    		})
    		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.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.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 myDevelopers = new Group("myDevelopers", GroupArgs.builder()        
                .path("/users/")
                .build());
    
            var myDeveloperPolicy = new GroupPolicy("myDeveloperPolicy", GroupPolicyArgs.builder()        
                .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 pulumi
    import json
    import pulumi_aws as aws
    
    my_developers = aws.iam.Group("myDevelopers", path="/users/")
    my_developer_policy = aws.iam.GroupPolicy("myDeveloperPolicy",
        group=my_developers.name,
        policy=json.dumps({
            "Version": "2012-10-17",
            "Statement": [{
                "Action": ["ec2:Describe*"],
                "Effect": "Allow",
                "Resource": "*",
            }],
        }))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const myDevelopers = new aws.iam.Group("myDevelopers", {path: "/users/"});
    const myDeveloperPolicy = new aws.iam.GroupPolicy("myDeveloperPolicy", {
        group: myDevelopers.name,
        policy: JSON.stringify({
            Version: "2012-10-17",
            Statement: [{
                Action: ["ec2:Describe*"],
                Effect: "Allow",
                Resource: "*",
            }],
        }),
    });
    
    resources:
      myDeveloperPolicy:
        type: aws:iam:GroupPolicy
        properties:
          group: ${myDevelopers.name}
          policy:
            fn::toJSON:
              Version: 2012-10-17
              Statement:
                - Action:
                    - ec2:Describe*
                  Effect: Allow
                  Resource: '*'
      myDevelopers:
        type: aws:iam:Group
        properties:
          path: /users/
    

    Create GroupPolicy Resource

    new GroupPolicy(name: string, args: GroupPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def GroupPolicy(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    group: Optional[str] = None,
                    name: Optional[str] = None,
                    name_prefix: Optional[str] = None,
                    policy: Optional[str] = None)
    @overload
    def GroupPolicy(resource_name: str,
                    args: GroupPolicyArgs,
                    opts: Optional[ResourceOptions] = None)
    func NewGroupPolicy(ctx *Context, name string, args GroupPolicyArgs, opts ...ResourceOption) (*GroupPolicy, error)
    public GroupPolicy(string name, GroupPolicyArgs args, CustomResourceOptions? opts = null)
    public GroupPolicy(String name, GroupPolicyArgs args)
    public GroupPolicy(String name, GroupPolicyArgs args, CustomResourceOptions options)
    
    type: aws:iam:GroupPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args GroupPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args GroupPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args GroupPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GroupPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GroupPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    GroupPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The GroupPolicy resource accepts the following input properties:

    Group string
    The IAM group to attach to the policy.
    Policy string | string
    The policy document. This is a JSON formatted string.
    Name string
    The name of the policy. If omitted, the provider will assign a random, unique name.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    Group string
    The IAM group to attach to the policy.
    Policy string | string
    The policy document. This is a JSON formatted string.
    Name string
    The name of the policy. If omitted, the provider will assign a random, unique name.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    group String
    The IAM group to attach to the policy.
    policy String | String
    The policy document. This is a JSON formatted string.
    name String
    The name of the policy. If omitted, the provider will assign a random, unique name.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    group string
    The IAM group to attach to the policy.
    policy string | PolicyDocument
    The policy document. This is a JSON formatted string.
    name string
    The name of the policy. If omitted, the provider will assign a random, unique name.
    namePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    group str
    The IAM group to attach to the policy.
    policy str | str
    The policy document. This is a JSON formatted string.
    name str
    The name of the policy. If omitted, the provider will assign a random, unique name.
    name_prefix str
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    group String
    The IAM group to attach to the policy.
    policy String |
    The policy document. This is a JSON formatted string.
    name String
    The name of the policy. If omitted, the provider will assign a random, unique name.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GroupPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing GroupPolicy Resource

    Get an existing GroupPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: GroupPolicyState, opts?: CustomResourceOptions): GroupPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group: Optional[str] = None,
            name: Optional[str] = None,
            name_prefix: Optional[str] = None,
            policy: Optional[str] = None) -> GroupPolicy
    func GetGroupPolicy(ctx *Context, name string, id IDInput, state *GroupPolicyState, opts ...ResourceOption) (*GroupPolicy, error)
    public static GroupPolicy Get(string name, Input<string> id, GroupPolicyState? state, CustomResourceOptions? opts = null)
    public static GroupPolicy get(String name, Output<String> id, GroupPolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Group string
    The IAM group to attach to the policy.
    Name string
    The name of the policy. If omitted, the provider will assign a random, unique name.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    Policy string | string
    The policy document. This is a JSON formatted string.
    Group string
    The IAM group to attach to the policy.
    Name string
    The name of the policy. If omitted, the provider will assign a random, unique name.
    NamePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    Policy string | string
    The policy document. This is a JSON formatted string.
    group String
    The IAM group to attach to the policy.
    name String
    The name of the policy. If omitted, the provider will assign a random, unique name.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    policy String | String
    The policy document. This is a JSON formatted string.
    group string
    The IAM group to attach to the policy.
    name string
    The name of the policy. If omitted, the provider will assign a random, unique name.
    namePrefix string
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    policy string | PolicyDocument
    The policy document. This is a JSON formatted string.
    group str
    The IAM group to attach to the policy.
    name str
    The name of the policy. If omitted, the provider will assign a random, unique name.
    name_prefix str
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    policy str | str
    The policy document. This is a JSON formatted string.
    group String
    The IAM group to attach to the policy.
    name String
    The name of the policy. If omitted, the provider will assign a random, unique name.
    namePrefix String
    Creates a unique name beginning with the specified prefix. Conflicts with name.
    policy String |
    The policy document. This is a JSON formatted string.

    Import

    Using pulumi import, import IAM Group Policies using the group_name:group_policy_name. For example:

     $ pulumi import aws:iam/groupPolicy:GroupPolicy mypolicy group_of_mypolicy_name:mypolicy_name
    

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi