1. Packages
  2. AWS
  3. API Docs
  4. iam
  5. GroupMembership
AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi

aws.iam.GroupMembership

Explore with Pulumi AI

aws logo
AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi

    WARNING: Multiple aws.iam.GroupMembership resources with the same group name will produce inconsistent behavior!

    Provides a top level resource to manage IAM Group membership for IAM Users. For more information on managing IAM Groups or IAM Users, see IAM Groups or IAM Users

    Note: aws.iam.GroupMembership will conflict with itself if used more than once with the same group. To non-exclusively manage the users in a group, see the aws.iam.UserGroupMembership resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const group = new aws.iam.Group("group", {name: "test-group"});
    const userOne = new aws.iam.User("user_one", {name: "test-user"});
    const userTwo = new aws.iam.User("user_two", {name: "test-user-two"});
    const team = new aws.iam.GroupMembership("team", {
        name: "tf-testing-group-membership",
        users: [
            userOne.name,
            userTwo.name,
        ],
        group: group.name,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    group = aws.iam.Group("group", name="test-group")
    user_one = aws.iam.User("user_one", name="test-user")
    user_two = aws.iam.User("user_two", name="test-user-two")
    team = aws.iam.GroupMembership("team",
        name="tf-testing-group-membership",
        users=[
            user_one.name,
            user_two.name,
        ],
        group=group.name)
    
    package main
    
    import (
    	"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 {
    		group, err := iam.NewGroup(ctx, "group", &iam.GroupArgs{
    			Name: pulumi.String("test-group"),
    		})
    		if err != nil {
    			return err
    		}
    		userOne, err := iam.NewUser(ctx, "user_one", &iam.UserArgs{
    			Name: pulumi.String("test-user"),
    		})
    		if err != nil {
    			return err
    		}
    		userTwo, err := iam.NewUser(ctx, "user_two", &iam.UserArgs{
    			Name: pulumi.String("test-user-two"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = iam.NewGroupMembership(ctx, "team", &iam.GroupMembershipArgs{
    			Name: pulumi.String("tf-testing-group-membership"),
    			Users: pulumi.StringArray{
    				userOne.Name,
    				userTwo.Name,
    			},
    			Group: group.Name,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var @group = new Aws.Iam.Group("group", new()
        {
            Name = "test-group",
        });
    
        var userOne = new Aws.Iam.User("user_one", new()
        {
            Name = "test-user",
        });
    
        var userTwo = new Aws.Iam.User("user_two", new()
        {
            Name = "test-user-two",
        });
    
        var team = new Aws.Iam.GroupMembership("team", new()
        {
            Name = "tf-testing-group-membership",
            Users = new[]
            {
                userOne.Name,
                userTwo.Name,
            },
            Group = @group.Name,
        });
    
    });
    
    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.User;
    import com.pulumi.aws.iam.UserArgs;
    import com.pulumi.aws.iam.GroupMembership;
    import com.pulumi.aws.iam.GroupMembershipArgs;
    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 group = new Group("group", GroupArgs.builder()
                .name("test-group")
                .build());
    
            var userOne = new User("userOne", UserArgs.builder()
                .name("test-user")
                .build());
    
            var userTwo = new User("userTwo", UserArgs.builder()
                .name("test-user-two")
                .build());
    
            var team = new GroupMembership("team", GroupMembershipArgs.builder()
                .name("tf-testing-group-membership")
                .users(            
                    userOne.name(),
                    userTwo.name())
                .group(group.name())
                .build());
    
        }
    }
    
    resources:
      team:
        type: aws:iam:GroupMembership
        properties:
          name: tf-testing-group-membership
          users:
            - ${userOne.name}
            - ${userTwo.name}
          group: ${group.name}
      group:
        type: aws:iam:Group
        properties:
          name: test-group
      userOne:
        type: aws:iam:User
        name: user_one
        properties:
          name: test-user
      userTwo:
        type: aws:iam:User
        name: user_two
        properties:
          name: test-user-two
    

    Create GroupMembership Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new GroupMembership(name: string, args: GroupMembershipArgs, opts?: CustomResourceOptions);
    @overload
    def GroupMembership(resource_name: str,
                        args: GroupMembershipArgs,
                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def GroupMembership(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        group: Optional[str] = None,
                        users: Optional[Sequence[str]] = None,
                        name: Optional[str] = None)
    func NewGroupMembership(ctx *Context, name string, args GroupMembershipArgs, opts ...ResourceOption) (*GroupMembership, error)
    public GroupMembership(string name, GroupMembershipArgs args, CustomResourceOptions? opts = null)
    public GroupMembership(String name, GroupMembershipArgs args)
    public GroupMembership(String name, GroupMembershipArgs args, CustomResourceOptions options)
    
    type: aws:iam:GroupMembership
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args GroupMembershipArgs
    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 GroupMembershipArgs
    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 GroupMembershipArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GroupMembershipArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GroupMembershipArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var groupMembershipResource = new Aws.Iam.GroupMembership("groupMembershipResource", new()
    {
        Group = "string",
        Users = new[]
        {
            "string",
        },
        Name = "string",
    });
    
    example, err := iam.NewGroupMembership(ctx, "groupMembershipResource", &iam.GroupMembershipArgs{
    	Group: pulumi.String("string"),
    	Users: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var groupMembershipResource = new GroupMembership("groupMembershipResource", GroupMembershipArgs.builder()
        .group("string")
        .users("string")
        .name("string")
        .build());
    
    group_membership_resource = aws.iam.GroupMembership("groupMembershipResource",
        group="string",
        users=["string"],
        name="string")
    
    const groupMembershipResource = new aws.iam.GroupMembership("groupMembershipResource", {
        group: "string",
        users: ["string"],
        name: "string",
    });
    
    type: aws:iam:GroupMembership
    properties:
        group: string
        name: string
        users:
            - string
    

    GroupMembership 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 GroupMembership resource accepts the following input properties:

    Group string
    The IAM Group name to attach the list of users to
    Users List<string>
    A list of IAM User names to associate with the Group
    Name string
    The name to identify the Group Membership
    Group string
    The IAM Group name to attach the list of users to
    Users []string
    A list of IAM User names to associate with the Group
    Name string
    The name to identify the Group Membership
    group String
    The IAM Group name to attach the list of users to
    users List<String>
    A list of IAM User names to associate with the Group
    name String
    The name to identify the Group Membership
    group string
    The IAM Group name to attach the list of users to
    users string[]
    A list of IAM User names to associate with the Group
    name string
    The name to identify the Group Membership
    group str
    The IAM Group name to attach the list of users to
    users Sequence[str]
    A list of IAM User names to associate with the Group
    name str
    The name to identify the Group Membership
    group String
    The IAM Group name to attach the list of users to
    users List<String>
    A list of IAM User names to associate with the Group
    name String
    The name to identify the Group Membership

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GroupMembership 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 GroupMembership Resource

    Get an existing GroupMembership 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?: GroupMembershipState, opts?: CustomResourceOptions): GroupMembership
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group: Optional[str] = None,
            name: Optional[str] = None,
            users: Optional[Sequence[str]] = None) -> GroupMembership
    func GetGroupMembership(ctx *Context, name string, id IDInput, state *GroupMembershipState, opts ...ResourceOption) (*GroupMembership, error)
    public static GroupMembership Get(string name, Input<string> id, GroupMembershipState? state, CustomResourceOptions? opts = null)
    public static GroupMembership get(String name, Output<String> id, GroupMembershipState 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 name to attach the list of users to
    Name string
    The name to identify the Group Membership
    Users List<string>
    A list of IAM User names to associate with the Group
    Group string
    The IAM Group name to attach the list of users to
    Name string
    The name to identify the Group Membership
    Users []string
    A list of IAM User names to associate with the Group
    group String
    The IAM Group name to attach the list of users to
    name String
    The name to identify the Group Membership
    users List<String>
    A list of IAM User names to associate with the Group
    group string
    The IAM Group name to attach the list of users to
    name string
    The name to identify the Group Membership
    users string[]
    A list of IAM User names to associate with the Group
    group str
    The IAM Group name to attach the list of users to
    name str
    The name to identify the Group Membership
    users Sequence[str]
    A list of IAM User names to associate with the Group
    group String
    The IAM Group name to attach the list of users to
    name String
    The name to identify the Group Membership
    users List<String>
    A list of IAM User names to associate with the Group

    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
    AWS v6.54.0 published on Friday, Sep 27, 2024 by Pulumi