UserGroupMembership

Provides a resource for adding an IAM User to IAM Groups. This resource can be used multiple times with the same user for non-overlapping groups.

To exclusively manage the users in a group, see the aws.iam.GroupMembership resource.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var user1 = new Aws.Iam.User("user1", new Aws.Iam.UserArgs
        {
        });
        var group1 = new Aws.Iam.Group("group1", new Aws.Iam.GroupArgs
        {
        });
        var group2 = new Aws.Iam.Group("group2", new Aws.Iam.GroupArgs
        {
        });
        var example1 = new Aws.Iam.UserGroupMembership("example1", new Aws.Iam.UserGroupMembershipArgs
        {
            User = user1.Name,
            Groups = 
            {
                group1.Name,
                group2.Name,
            },
        });
        var group3 = new Aws.Iam.Group("group3", new Aws.Iam.GroupArgs
        {
        });
        var example2 = new Aws.Iam.UserGroupMembership("example2", new Aws.Iam.UserGroupMembershipArgs
        {
            User = user1.Name,
            Groups = 
            {
                group3.Name,
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		user1, err := iam.NewUser(ctx, "user1", nil)
		if err != nil {
			return err
		}
		group1, err := iam.NewGroup(ctx, "group1", nil)
		if err != nil {
			return err
		}
		group2, err := iam.NewGroup(ctx, "group2", nil)
		if err != nil {
			return err
		}
		_, err = iam.NewUserGroupMembership(ctx, "example1", &iam.UserGroupMembershipArgs{
			User: user1.Name,
			Groups: pulumi.StringArray{
				group1.Name,
				group2.Name,
			},
		})
		if err != nil {
			return err
		}
		group3, err := iam.NewGroup(ctx, "group3", nil)
		if err != nil {
			return err
		}
		_, err = iam.NewUserGroupMembership(ctx, "example2", &iam.UserGroupMembershipArgs{
			User: user1.Name,
			Groups: pulumi.StringArray{
				group3.Name,
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

user1 = aws.iam.User("user1")
group1 = aws.iam.Group("group1")
group2 = aws.iam.Group("group2")
example1 = aws.iam.UserGroupMembership("example1",
    user=user1.name,
    groups=[
        group1.name,
        group2.name,
    ])
group3 = aws.iam.Group("group3")
example2 = aws.iam.UserGroupMembership("example2",
    user=user1.name,
    groups=[group3.name])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const user1 = new aws.iam.User("user1", {});
const group1 = new aws.iam.Group("group1", {});
const group2 = new aws.iam.Group("group2", {});
const example1 = new aws.iam.UserGroupMembership("example1", {
    user: user1.name,
    groups: [
        group1.name,
        group2.name,
    ],
});
const group3 = new aws.iam.Group("group3", {});
const example2 = new aws.iam.UserGroupMembership("example2", {
    user: user1.name,
    groups: [group3.name],
});

Create a UserGroupMembership Resource

new UserGroupMembership(name: string, args: UserGroupMembershipArgs, opts?: CustomResourceOptions);
@overload
def UserGroupMembership(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        groups: Optional[Sequence[str]] = None,
                        user: Optional[str] = None)
@overload
def UserGroupMembership(resource_name: str,
                        args: UserGroupMembershipArgs,
                        opts: Optional[ResourceOptions] = None)
func NewUserGroupMembership(ctx *Context, name string, args UserGroupMembershipArgs, opts ...ResourceOption) (*UserGroupMembership, error)
public UserGroupMembership(string name, UserGroupMembershipArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args UserGroupMembershipArgs
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 UserGroupMembershipArgs
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 UserGroupMembershipArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UserGroupMembershipArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

UserGroupMembership Resource Properties

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

Inputs

The UserGroupMembership resource accepts the following input properties:

Groups List<string>
A list of IAM Groups to add the user to
User string
The name of the IAM User to add to groups
Groups []string
A list of IAM Groups to add the user to
User string
The name of the IAM User to add to groups
groups string[]
A list of IAM Groups to add the user to
user string
The name of the IAM User to add to groups
groups Sequence[str]
A list of IAM Groups to add the user to
user str
The name of the IAM User to add to groups

Outputs

All input properties are implicitly available as output properties. Additionally, the UserGroupMembership 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing UserGroupMembership Resource

Get an existing UserGroupMembership 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?: UserGroupMembershipState, opts?: CustomResourceOptions): UserGroupMembership
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        groups: Optional[Sequence[str]] = None,
        user: Optional[str] = None) -> UserGroupMembership
func GetUserGroupMembership(ctx *Context, name string, id IDInput, state *UserGroupMembershipState, opts ...ResourceOption) (*UserGroupMembership, error)
public static UserGroupMembership Get(string name, Input<string> id, UserGroupMembershipState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

Groups List<string>
A list of IAM Groups to add the user to
User string
The name of the IAM User to add to groups
Groups []string
A list of IAM Groups to add the user to
User string
The name of the IAM User to add to groups
groups string[]
A list of IAM Groups to add the user to
user string
The name of the IAM User to add to groups
groups Sequence[str]
A list of IAM Groups to add the user to
user str
The name of the IAM User to add to groups

Import

IAM user group membership can be imported using the user name and group names separated by /.

 $ pulumi import aws:iam/userGroupMembership:UserGroupMembership example1 user1/group1/group2

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.