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

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.GroupMembership

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

    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

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

    Create GroupMembership Resource

    new GroupMembership(name: string, args: GroupMembershipArgs, opts?: CustomResourceOptions);
    @overload
    def GroupMembership(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        group: Optional[str] = None,
                        name: Optional[str] = None,
                        users: Optional[Sequence[str]] = None)
    @overload
    def GroupMembership(resource_name: str,
                        args: GroupMembershipArgs,
                        opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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

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

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