Class KeyPairAttachment
Provides a key pair attachment resource to bind key pair for several ECS instances.
NOTE: After the key pair is attached with sone instances, there instances must be rebooted to make the key pair affect.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
class MyStack : Stack
{
public MyStack()
{
var @default = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
{
AvailableDiskCategory = "cloud_ssd",
AvailableResourceCreation = "VSwitch",
}));
var type = @default.Apply(@default => Output.Create(AliCloud.Ecs.GetInstanceTypes.InvokeAsync(new AliCloud.Ecs.GetInstanceTypesArgs
{
AvailabilityZone = @default.Zones[0].Id,
CpuCoreCount = 1,
MemorySize = 2,
})));
var images = Output.Create(AliCloud.Ecs.GetImages.InvokeAsync(new AliCloud.Ecs.GetImagesArgs
{
MostRecent = true,
NameRegex = "^ubuntu_18.*64",
Owners = "system",
}));
var config = new Config();
var name = config.Get("name") ?? "keyPairAttachmentName";
var vpc = new AliCloud.Vpc.Network("vpc", new AliCloud.Vpc.NetworkArgs
{
CidrBlock = "10.1.0.0/21",
});
var vswitch = new AliCloud.Vpc.Switch("vswitch", new AliCloud.Vpc.SwitchArgs
{
AvailabilityZone = @default.Apply(@default => @default.Zones[0].Id),
CidrBlock = "10.1.1.0/24",
VpcId = vpc.Id,
});
var @group = new AliCloud.Ecs.SecurityGroup("group", new AliCloud.Ecs.SecurityGroupArgs
{
Description = "New security group",
VpcId = vpc.Id,
});
var instance = new List<AliCloud.Ecs.Instance>();
for (var rangeIndex = 0; rangeIndex < 2; rangeIndex++)
{
var range = new { Value = rangeIndex };
instance.Add(new AliCloud.Ecs.Instance($"instance-{range.Value}", new AliCloud.Ecs.InstanceArgs
{
ImageId = images.Apply(images => images.Images[0].Id),
InstanceChargeType = "PostPaid",
InstanceName = $"{name}-{range.Value + 1}",
InstanceType = type.Apply(type => type.InstanceTypes[0].Id),
InternetChargeType = "PayByTraffic",
InternetMaxBandwidthOut = 5,
Password = "Test12345",
SecurityGroups =
{
@group.Id,
},
SystemDiskCategory = "cloud_ssd",
VswitchId = vswitch.Id,
}));
}
var pair = new AliCloud.Ecs.KeyPair("pair", new AliCloud.Ecs.KeyPairArgs
{
KeyName = name,
});
var attachment = new AliCloud.Ecs.KeyPairAttachment("attachment", new AliCloud.Ecs.KeyPairAttachmentArgs
{
InstanceIds = instance.Select(__item => __item.Id).ToList(),
KeyName = pair.Id,
});
}
}
Inherited Members
Namespace: Pulumi.AliCloud.Ecs
Assembly: Pulumi.AliCloud.dll
Syntax
public class KeyPairAttachment : CustomResource
Constructors
View SourceKeyPairAttachment(String, KeyPairAttachmentArgs, CustomResourceOptions)
Create a KeyPairAttachment resource with the given unique name, arguments, and options.
Declaration
public KeyPairAttachment(string name, KeyPairAttachmentArgs args, CustomResourceOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The unique name of the resource |
| KeyPairAttachmentArgs | args | The arguments used to populate this resource's properties |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Properties
View SourceForce
Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
Declaration
public Output<bool?> Force { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.Nullable<System.Boolean>> |
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>> |
KeyName
The name of key pair used to bind.
Declaration
public Output<string> KeyName { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(String, Input<String>, KeyPairAttachmentState, CustomResourceOptions)
Get an existing KeyPairAttachment resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
Declaration
public static KeyPairAttachment Get(string name, Input<string> id, KeyPairAttachmentState 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. |
| KeyPairAttachmentState | state | Any extra arguments used during the lookup. |
| CustomResourceOptions | options | A bag of options that control this resource's behavior |
Returns
| Type | Description |
|---|---|
| KeyPairAttachment |