alicloud.ram.UserGroupAttachment
Explore with Pulumi AI
Provides a RAM User Group Attachment resource.
For information about RAM User Group Attachment and how to use it, see What is User Group Attachment.
NOTE: Available since v1.245.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as random from "@pulumi/random";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = new random.index.Integer("default", {
min: 10000,
max: 99999,
});
const defaultUser = new alicloud.ram.User("default", {
name: `terraform-example-${_default.result}`,
displayName: `terraform-example-${_default.result}`,
});
const defaultGroup = new alicloud.ram.Group("default", {name: `terraform-example-${_default.result}`});
const defaultUserGroupAttachment = new alicloud.ram.UserGroupAttachment("default", {
groupName: defaultGroup.id,
userName: defaultUser.name,
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_random as random
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = random.index.Integer("default",
min=10000,
max=99999)
default_user = alicloud.ram.User("default",
name=f"terraform-example-{default['result']}",
display_name=f"terraform-example-{default['result']}")
default_group = alicloud.ram.Group("default", name=f"terraform-example-{default['result']}")
default_user_group_attachment = alicloud.ram.UserGroupAttachment("default",
group_name=default_group.id,
user_name=default_user.name)
package main
import (
"fmt"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ram"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
Min: 10000,
Max: 99999,
})
if err != nil {
return err
}
defaultUser, err := ram.NewUser(ctx, "default", &ram.UserArgs{
Name: pulumi.Sprintf("terraform-example-%v", _default.Result),
DisplayName: pulumi.Sprintf("terraform-example-%v", _default.Result),
})
if err != nil {
return err
}
defaultGroup, err := ram.NewGroup(ctx, "default", &ram.GroupArgs{
Name: pulumi.Sprintf("terraform-example-%v", _default.Result),
})
if err != nil {
return err
}
_, err = ram.NewUserGroupAttachment(ctx, "default", &ram.UserGroupAttachmentArgs{
GroupName: defaultGroup.ID(),
UserName: defaultUser.Name,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = new Random.Index.Integer("default", new()
{
Min = 10000,
Max = 99999,
});
var defaultUser = new AliCloud.Ram.User("default", new()
{
Name = $"terraform-example-{@default.Result}",
DisplayName = $"terraform-example-{@default.Result}",
});
var defaultGroup = new AliCloud.Ram.Group("default", new()
{
Name = $"terraform-example-{@default.Result}",
});
var defaultUserGroupAttachment = new AliCloud.Ram.UserGroupAttachment("default", new()
{
GroupName = defaultGroup.Id,
UserName = defaultUser.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.integer;
import com.pulumi.random.IntegerArgs;
import com.pulumi.alicloud.ram.User;
import com.pulumi.alicloud.ram.UserArgs;
import com.pulumi.alicloud.ram.Group;
import com.pulumi.alicloud.ram.GroupArgs;
import com.pulumi.alicloud.ram.UserGroupAttachment;
import com.pulumi.alicloud.ram.UserGroupAttachmentArgs;
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) {
final var config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
var default_ = new Integer("default", IntegerArgs.builder()
.min(10000)
.max(99999)
.build());
var defaultUser = new User("defaultUser", UserArgs.builder()
.name(String.format("terraform-example-%s", default_.result()))
.displayName(String.format("terraform-example-%s", default_.result()))
.build());
var defaultGroup = new Group("defaultGroup", GroupArgs.builder()
.name(String.format("terraform-example-%s", default_.result()))
.build());
var defaultUserGroupAttachment = new UserGroupAttachment("defaultUserGroupAttachment", UserGroupAttachmentArgs.builder()
.groupName(defaultGroup.id())
.userName(defaultUser.name())
.build());
}
}
configuration:
name:
type: string
default: terraform-example
resources:
default:
type: random:integer
properties:
min: 10000
max: 99999
defaultUser:
type: alicloud:ram:User
name: default
properties:
name: terraform-example-${default.result}
displayName: terraform-example-${default.result}
defaultGroup:
type: alicloud:ram:Group
name: default
properties:
name: terraform-example-${default.result}
defaultUserGroupAttachment:
type: alicloud:ram:UserGroupAttachment
name: default
properties:
groupName: ${defaultGroup.id}
userName: ${defaultUser.name}
Create UserGroupAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserGroupAttachment(name: string, args: UserGroupAttachmentArgs, opts?: CustomResourceOptions);
@overload
def UserGroupAttachment(resource_name: str,
args: UserGroupAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def UserGroupAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
group_name: Optional[str] = None,
user_name: Optional[str] = None)
func NewUserGroupAttachment(ctx *Context, name string, args UserGroupAttachmentArgs, opts ...ResourceOption) (*UserGroupAttachment, error)
public UserGroupAttachment(string name, UserGroupAttachmentArgs args, CustomResourceOptions? opts = null)
public UserGroupAttachment(String name, UserGroupAttachmentArgs args)
public UserGroupAttachment(String name, UserGroupAttachmentArgs args, CustomResourceOptions options)
type: alicloud:ram:UserGroupAttachment
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 UserGroupAttachmentArgs
- 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 UserGroupAttachmentArgs
- 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 UserGroupAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserGroupAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserGroupAttachmentArgs
- 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 userGroupAttachmentResource = new AliCloud.Ram.UserGroupAttachment("userGroupAttachmentResource", new()
{
GroupName = "string",
UserName = "string",
});
example, err := ram.NewUserGroupAttachment(ctx, "userGroupAttachmentResource", &ram.UserGroupAttachmentArgs{
GroupName: pulumi.String("string"),
UserName: pulumi.String("string"),
})
var userGroupAttachmentResource = new UserGroupAttachment("userGroupAttachmentResource", UserGroupAttachmentArgs.builder()
.groupName("string")
.userName("string")
.build());
user_group_attachment_resource = alicloud.ram.UserGroupAttachment("userGroupAttachmentResource",
group_name="string",
user_name="string")
const userGroupAttachmentResource = new alicloud.ram.UserGroupAttachment("userGroupAttachmentResource", {
groupName: "string",
userName: "string",
});
type: alicloud:ram:UserGroupAttachment
properties:
groupName: string
userName: string
UserGroupAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The UserGroupAttachment resource accepts the following input properties:
- group_
name str - The name of group.
- user_
name str - The name of user.
Outputs
All input properties are implicitly available as output properties. Additionally, the UserGroupAttachment 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 UserGroupAttachment Resource
Get an existing UserGroupAttachment 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?: UserGroupAttachmentState, opts?: CustomResourceOptions): UserGroupAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
group_name: Optional[str] = None,
user_name: Optional[str] = None) -> UserGroupAttachment
func GetUserGroupAttachment(ctx *Context, name string, id IDInput, state *UserGroupAttachmentState, opts ...ResourceOption) (*UserGroupAttachment, error)
public static UserGroupAttachment Get(string name, Input<string> id, UserGroupAttachmentState? state, CustomResourceOptions? opts = null)
public static UserGroupAttachment get(String name, Output<String> id, UserGroupAttachmentState state, CustomResourceOptions options)
resources: _: type: alicloud:ram:UserGroupAttachment get: id: ${id}
- 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.
- group_
name str - The name of group.
- user_
name str - The name of user.
Import
RAM User Group Attachment can be imported using the id, e.g.
$ pulumi import alicloud:ram/userGroupAttachment:UserGroupAttachment example <group_name>:<user_name>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.