Show / Hide Table of Contents

Class RoleAttachment

Provides a RAM role attachment resource to bind role for several ECS instances.

Example Usage

using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
public MyStack()
{
    var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
    {
        AvailableDiskCategory = "cloud_efficiency",
        AvailableResourceCreation = "VSwitch",
    }));
    var defaultInstanceTypes = defaultZones.Apply(defaultZones => Output.Create(AliCloud.Ecs.GetInstanceTypes.InvokeAsync(new AliCloud.Ecs.GetInstanceTypesArgs
    {
        AvailabilityZone = defaultZones.Zones[0].Id,
        CpuCoreCount = 2,
        MemorySize = 4,
    })));
    var defaultImages = Output.Create(AliCloud.Ecs.GetImages.InvokeAsync(new AliCloud.Ecs.GetImagesArgs
    {
        MostRecent = true,
        NameRegex = "^ubuntu_18.*64",
        Owners = "system",
    }));
    var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
    {
        CidrBlock = "172.16.0.0/16",
    });
    var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
    {
        AvailabilityZone = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
        CidrBlock = "172.16.0.0/24",
        VpcId = defaultNetwork.Id,
    });
    var defaultSecurityGroup = new AliCloud.Ecs.SecurityGroup("defaultSecurityGroup", new AliCloud.Ecs.SecurityGroupArgs
    {
        VpcId = defaultNetwork.Id,
    });
    var defaultSecurityGroupRule = new AliCloud.Ecs.SecurityGroupRule("defaultSecurityGroupRule", new AliCloud.Ecs.SecurityGroupRuleArgs
    {
        CidrIp = "172.16.0.0/24",
        IpProtocol = "tcp",
        NicType = "intranet",
        Policy = "accept",
        PortRange = "22/22",
        Priority = 1,
        SecurityGroupId = defaultSecurityGroup.Id,
        Type = "ingress",
    });
    var config = new Config();
    var name = config.Get("name") ?? "ecsInstanceVPCExample";
    var foo = new AliCloud.Ecs.Instance("foo", new AliCloud.Ecs.InstanceArgs
    {
        ImageId = defaultImages.Apply(defaultImages => defaultImages.Images[0].Id),
        InstanceName = name,
        InstanceType = defaultInstanceTypes.Apply(defaultInstanceTypes => defaultInstanceTypes.InstanceTypes[0].Id),
        InternetChargeType = "PayByTraffic",
        InternetMaxBandwidthOut = 5,
        SecurityGroups = 
        {
            defaultSecurityGroup.Id,
        },
        SystemDiskCategory = "cloud_efficiency",
        VswitchId = defaultSwitch.Id,
    });
    var role = new AliCloud.Ram.Role("role", new AliCloud.Ram.RoleArgs
    {
        Description = "this is a test",
        Document = @"  {
""Statement"": [
  {
    ""Action"": ""sts:AssumeRole"",
    ""Effect"": ""Allow"",
    ""Principal"": {
      ""Service"": [
        ""ecs.aliyuncs.com""
      ]
    }
  }
],
""Version"": ""1""
}

",
        Force = true,
    });
    var attach = new AliCloud.Ram.RoleAttachment("attach", new AliCloud.Ram.RoleAttachmentArgs
    {
        InstanceIds = 
        {

            {
                foo,
            }.Select(__item => __item.Id).ToList(),
        },
        RoleName = role.Name,
    });
}

}
Inheritance
System.Object
Resource
CustomResource
RoleAttachment
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.AliCloud.Ram
Assembly: Pulumi.AliCloud.dll
Syntax
public class RoleAttachment : CustomResource

Constructors

View Source

RoleAttachment(String, RoleAttachmentArgs, CustomResourceOptions)

Create a RoleAttachment resource with the given unique name, arguments, and options.

Declaration
public RoleAttachment(string name, RoleAttachmentArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

RoleAttachmentArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

InstanceIds

The list of ECS instance's IDs.

Declaration
public Output<ImmutableArray<string>> InstanceIds { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

RoleName

The name of role used to bind. This name can have a string of 1 to 64 characters, must contain only alphanumeric characters or hyphens, such as "-", "_", and must not begin with a hyphen.

Declaration
public Output<string> RoleName { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, RoleAttachmentState, CustomResourceOptions)

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

Declaration
public static RoleAttachment Get(string name, Input<string> id, RoleAttachmentState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

RoleAttachmentState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
RoleAttachment
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.