1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ecs
  5. KeyPairAttachment
Alibaba Cloud v3.59.0 published on Friday, Jul 12, 2024 by Pulumi

alicloud.ecs.KeyPairAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.59.0 published on Friday, Jul 12, 2024 by Pulumi

    DEPRECATED: This resource has been renamed to alicloud.ecs.EcsKeyPairAttachment from version 1.121.0.

    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

    Basic Usage

    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    Coming soon!
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.AlicloudFunctions;
    import com.pulumi.alicloud.inputs.GetZonesArgs;
    import com.pulumi.alicloud.ecs.EcsFunctions;
    import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
    import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
    import com.pulumi.alicloud.vpc.Network;
    import com.pulumi.alicloud.vpc.NetworkArgs;
    import com.pulumi.alicloud.vpc.Switch;
    import com.pulumi.alicloud.vpc.SwitchArgs;
    import com.pulumi.alicloud.ecs.SecurityGroup;
    import com.pulumi.alicloud.ecs.SecurityGroupArgs;
    import com.pulumi.alicloud.ecs.Instance;
    import com.pulumi.alicloud.ecs.InstanceArgs;
    import com.pulumi.alicloud.ecs.KeyPair;
    import com.pulumi.alicloud.ecs.KeyPairArgs;
    import com.pulumi.alicloud.ecs.KeyPairAttachment;
    import com.pulumi.alicloud.ecs.KeyPairAttachmentArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    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 default = AlicloudFunctions.getZones(GetZonesArgs.builder()
                .availableDiskCategory("cloud_ssd")
                .availableResourceCreation("VSwitch")
                .build());
    
            final var type = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
                .avaiabilityZone(default_.zones()[0].id())
                .cpuCoreCount(1)
                .memorySize(2)
                .build());
    
            final var images = EcsFunctions.getImages(GetImagesArgs.builder()
                .nameRegex("^ubuntu_18.*64")
                .mostRecent(true)
                .owners("system")
                .build());
    
            final var name = config.get("name").orElse("keyPairAttachmentName");
            var vpc = new Network("vpc", NetworkArgs.builder()
                .vpcName(name)
                .cidrBlock("10.1.0.0/21")
                .build());
    
            var vswitch = new Switch("vswitch", SwitchArgs.builder()
                .vpcId(vpc.id())
                .cidrBlock("10.1.1.0/24")
                .zoneId(default_.zones()[0].id())
                .vswitchName(name)
                .build());
    
            var group = new SecurityGroup("group", SecurityGroupArgs.builder()
                .name(name)
                .description("New security group")
                .vpcId(vpc.id())
                .build());
    
            for (var i = 0; i < 2; i++) {
                new Instance("instance-" + i, InstanceArgs.builder()
                    .instanceName(String.format("%s-%s", name,range.value() + 1))
                    .imageId(images.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
                    .instanceType(type.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
                    .securityGroups(group.id())
                    .vswitchId(vswitch.id())
                    .internetChargeType("PayByTraffic")
                    .internetMaxBandwidthOut(5)
                    .password("Test12345")
                    .instanceChargeType("PostPaid")
                    .systemDiskCategory("cloud_ssd")
                    .build());
    
            
    }
            var pair = new KeyPair("pair", KeyPairArgs.builder()
                .keyName(name)
                .build());
    
            var attachment = new KeyPairAttachment("attachment", KeyPairAttachmentArgs.builder()
                .keyName(pair.id())
                .instanceIds(instance.stream().map(element -> element.id()).collect(toList()))
                .build());
    
        }
    }
    
    Coming soon!
    

    Create KeyPairAttachment Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new KeyPairAttachment(name: string, args: KeyPairAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def KeyPairAttachment(resource_name: str,
                          args: KeyPairAttachmentArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def KeyPairAttachment(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          instance_ids: Optional[Sequence[str]] = None,
                          force: Optional[bool] = None,
                          key_name: Optional[str] = None,
                          key_pair_name: Optional[str] = None)
    func NewKeyPairAttachment(ctx *Context, name string, args KeyPairAttachmentArgs, opts ...ResourceOption) (*KeyPairAttachment, error)
    public KeyPairAttachment(string name, KeyPairAttachmentArgs args, CustomResourceOptions? opts = null)
    public KeyPairAttachment(String name, KeyPairAttachmentArgs args)
    public KeyPairAttachment(String name, KeyPairAttachmentArgs args, CustomResourceOptions options)
    
    type: alicloud:ecs:KeyPairAttachment
    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 KeyPairAttachmentArgs
    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 KeyPairAttachmentArgs
    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 KeyPairAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args KeyPairAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args KeyPairAttachmentArgs
    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 keyPairAttachmentResource = new AliCloud.Ecs.KeyPairAttachment("keyPairAttachmentResource", new()
    {
        InstanceIds = new[]
        {
            "string",
        },
        Force = false,
        KeyPairName = "string",
    });
    
    example, err := ecs.NewKeyPairAttachment(ctx, "keyPairAttachmentResource", &ecs.KeyPairAttachmentArgs{
    	InstanceIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Force:       pulumi.Bool(false),
    	KeyPairName: pulumi.String("string"),
    })
    
    var keyPairAttachmentResource = new KeyPairAttachment("keyPairAttachmentResource", KeyPairAttachmentArgs.builder()
        .instanceIds("string")
        .force(false)
        .keyPairName("string")
        .build());
    
    key_pair_attachment_resource = alicloud.ecs.KeyPairAttachment("keyPairAttachmentResource",
        instance_ids=["string"],
        force=False,
        key_pair_name="string")
    
    const keyPairAttachmentResource = new alicloud.ecs.KeyPairAttachment("keyPairAttachmentResource", {
        instanceIds: ["string"],
        force: false,
        keyPairName: "string",
    });
    
    type: alicloud:ecs:KeyPairAttachment
    properties:
        force: false
        instanceIds:
            - string
        keyPairName: string
    

    KeyPairAttachment 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 KeyPairAttachment resource accepts the following input properties:

    InstanceIds List<string>
    The list of ECS instance's IDs.
    Force bool
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    KeyName string
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    KeyPairName string
    InstanceIds []string
    The list of ECS instance's IDs.
    Force bool
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    KeyName string
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    KeyPairName string
    instanceIds List<String>
    The list of ECS instance's IDs.
    force Boolean
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    keyName String
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    keyPairName String
    instanceIds string[]
    The list of ECS instance's IDs.
    force boolean
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    keyName string
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    keyPairName string
    instance_ids Sequence[str]
    The list of ECS instance's IDs.
    force bool
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    key_name str
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    key_pair_name str
    instanceIds List<String>
    The list of ECS instance's IDs.
    force Boolean
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    keyName String
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    keyPairName String

    Outputs

    All input properties are implicitly available as output properties. Additionally, the KeyPairAttachment 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 KeyPairAttachment Resource

    Get an existing KeyPairAttachment 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?: KeyPairAttachmentState, opts?: CustomResourceOptions): KeyPairAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            force: Optional[bool] = None,
            instance_ids: Optional[Sequence[str]] = None,
            key_name: Optional[str] = None,
            key_pair_name: Optional[str] = None) -> KeyPairAttachment
    func GetKeyPairAttachment(ctx *Context, name string, id IDInput, state *KeyPairAttachmentState, opts ...ResourceOption) (*KeyPairAttachment, error)
    public static KeyPairAttachment Get(string name, Input<string> id, KeyPairAttachmentState? state, CustomResourceOptions? opts = null)
    public static KeyPairAttachment get(String name, Output<String> id, KeyPairAttachmentState 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:
    Force bool
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    InstanceIds List<string>
    The list of ECS instance's IDs.
    KeyName string
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    KeyPairName string
    Force bool
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    InstanceIds []string
    The list of ECS instance's IDs.
    KeyName string
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    KeyPairName string
    force Boolean
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    instanceIds List<String>
    The list of ECS instance's IDs.
    keyName String
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    keyPairName String
    force boolean
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    instanceIds string[]
    The list of ECS instance's IDs.
    keyName string
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    keyPairName string
    force bool
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    instance_ids Sequence[str]
    The list of ECS instance's IDs.
    key_name str
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    key_pair_name str
    force Boolean
    Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
    instanceIds List<String>
    The list of ECS instance's IDs.
    keyName String
    The name of key pair used to bind.

    Deprecated: Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead.

    keyPairName String

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.59.0 published on Friday, Jul 12, 2024 by Pulumi