1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. ecs
  5. KeyPair
Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi

alicloud.ecs.KeyPair

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi

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

    Provides a key pair resource.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const basic = new alicloud.ecs.KeyPair("basic", {keyName: "terraform-test-key-pair"});
    // Using name prefix to build key pair
    const prefix = new alicloud.ecs.KeyPair("prefix", {keyNamePrefix: "terraform-test-key-pair-prefix"});
    // Import an existing public key to build a alicloud key pair
    const publickey = new alicloud.ecs.KeyPair("publickey", {
        keyName: "my_public_key",
        publicKey: "ssh-rsa AAAAB3Nza12345678qwertyuudsfsg",
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    basic = alicloud.ecs.KeyPair("basic", key_name="terraform-test-key-pair")
    # Using name prefix to build key pair
    prefix = alicloud.ecs.KeyPair("prefix", key_name_prefix="terraform-test-key-pair-prefix")
    # Import an existing public key to build a alicloud key pair
    publickey = alicloud.ecs.KeyPair("publickey",
        key_name="my_public_key",
        public_key="ssh-rsa AAAAB3Nza12345678qwertyuudsfsg")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ecs.NewKeyPair(ctx, "basic", &ecs.KeyPairArgs{
    			KeyName: pulumi.String("terraform-test-key-pair"),
    		})
    		if err != nil {
    			return err
    		}
    		// Using name prefix to build key pair
    		_, err = ecs.NewKeyPair(ctx, "prefix", &ecs.KeyPairArgs{
    			KeyNamePrefix: pulumi.String("terraform-test-key-pair-prefix"),
    		})
    		if err != nil {
    			return err
    		}
    		// Import an existing public key to build a alicloud key pair
    		_, err = ecs.NewKeyPair(ctx, "publickey", &ecs.KeyPairArgs{
    			KeyName:   pulumi.String("my_public_key"),
    			PublicKey: pulumi.String("ssh-rsa AAAAB3Nza12345678qwertyuudsfsg"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var basic = new AliCloud.Ecs.KeyPair("basic", new()
        {
            KeyName = "terraform-test-key-pair",
        });
    
        // Using name prefix to build key pair
        var prefix = new AliCloud.Ecs.KeyPair("prefix", new()
        {
            KeyNamePrefix = "terraform-test-key-pair-prefix",
        });
    
        // Import an existing public key to build a alicloud key pair
        var publickey = new AliCloud.Ecs.KeyPair("publickey", new()
        {
            KeyName = "my_public_key",
            PublicKey = "ssh-rsa AAAAB3Nza12345678qwertyuudsfsg",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.ecs.KeyPair;
    import com.pulumi.alicloud.ecs.KeyPairArgs;
    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) {
            var basic = new KeyPair("basic", KeyPairArgs.builder()
                .keyName("terraform-test-key-pair")
                .build());
    
            // Using name prefix to build key pair
            var prefix = new KeyPair("prefix", KeyPairArgs.builder()
                .keyNamePrefix("terraform-test-key-pair-prefix")
                .build());
    
            // Import an existing public key to build a alicloud key pair
            var publickey = new KeyPair("publickey", KeyPairArgs.builder()
                .keyName("my_public_key")
                .publicKey("ssh-rsa AAAAB3Nza12345678qwertyuudsfsg")
                .build());
    
        }
    }
    
    resources:
      basic:
        type: alicloud:ecs:KeyPair
        properties:
          keyName: terraform-test-key-pair
      # Using name prefix to build key pair
      prefix:
        type: alicloud:ecs:KeyPair
        properties:
          keyNamePrefix: terraform-test-key-pair-prefix
      # Import an existing public key to build a alicloud key pair
      publickey:
        type: alicloud:ecs:KeyPair
        properties:
          keyName: my_public_key
          publicKey: ssh-rsa AAAAB3Nza12345678qwertyuudsfsg
    

    Create KeyPair Resource

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

    Constructor syntax

    new KeyPair(name: string, args?: KeyPairArgs, opts?: CustomResourceOptions);
    @overload
    def KeyPair(resource_name: str,
                args: Optional[KeyPairArgs] = None,
                opts: Optional[ResourceOptions] = None)
    
    @overload
    def KeyPair(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                key_file: Optional[str] = None,
                key_name: Optional[str] = None,
                key_name_prefix: Optional[str] = None,
                key_pair_name: Optional[str] = None,
                public_key: Optional[str] = None,
                resource_group_id: Optional[str] = None,
                tags: Optional[Mapping[str, str]] = None)
    func NewKeyPair(ctx *Context, name string, args *KeyPairArgs, opts ...ResourceOption) (*KeyPair, error)
    public KeyPair(string name, KeyPairArgs? args = null, CustomResourceOptions? opts = null)
    public KeyPair(String name, KeyPairArgs args)
    public KeyPair(String name, KeyPairArgs args, CustomResourceOptions options)
    
    type: alicloud:ecs:KeyPair
    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 KeyPairArgs
    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 KeyPairArgs
    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 KeyPairArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args KeyPairArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args KeyPairArgs
    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 alicloudKeyPairResource = new AliCloud.Ecs.KeyPair("alicloudKeyPairResource", new()
    {
        KeyFile = "string",
        KeyNamePrefix = "string",
        KeyPairName = "string",
        PublicKey = "string",
        ResourceGroupId = "string",
        Tags = 
        {
            { "string", "string" },
        },
    });
    
    example, err := ecs.NewKeyPair(ctx, "alicloudKeyPairResource", &ecs.KeyPairArgs{
    	KeyFile:         pulumi.String("string"),
    	KeyNamePrefix:   pulumi.String("string"),
    	KeyPairName:     pulumi.String("string"),
    	PublicKey:       pulumi.String("string"),
    	ResourceGroupId: pulumi.String("string"),
    	Tags: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    })
    
    var alicloudKeyPairResource = new KeyPair("alicloudKeyPairResource", KeyPairArgs.builder()
        .keyFile("string")
        .keyNamePrefix("string")
        .keyPairName("string")
        .publicKey("string")
        .resourceGroupId("string")
        .tags(Map.of("string", "string"))
        .build());
    
    alicloud_key_pair_resource = alicloud.ecs.KeyPair("alicloudKeyPairResource",
        key_file="string",
        key_name_prefix="string",
        key_pair_name="string",
        public_key="string",
        resource_group_id="string",
        tags={
            "string": "string",
        })
    
    const alicloudKeyPairResource = new alicloud.ecs.KeyPair("alicloudKeyPairResource", {
        keyFile: "string",
        keyNamePrefix: "string",
        keyPairName: "string",
        publicKey: "string",
        resourceGroupId: "string",
        tags: {
            string: "string",
        },
    });
    
    type: alicloud:ecs:KeyPair
    properties:
        keyFile: string
        keyNamePrefix: string
        keyPairName: string
        publicKey: string
        resourceGroupId: string
        tags:
            string: string
    

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

    KeyFile string
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    KeyName string
    The key pair's name. It is the only in one Alicloud account.

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

    KeyNamePrefix string
    KeyPairName string
    PublicKey string
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    ResourceGroupId string
    The Id of resource group which the key pair belongs.
    Tags Dictionary<string, string>
    KeyFile string
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    KeyName string
    The key pair's name. It is the only in one Alicloud account.

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

    KeyNamePrefix string
    KeyPairName string
    PublicKey string
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    ResourceGroupId string
    The Id of resource group which the key pair belongs.
    Tags map[string]string
    keyFile String
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    keyName String
    The key pair's name. It is the only in one Alicloud account.

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

    keyNamePrefix String
    keyPairName String
    publicKey String
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resourceGroupId String
    The Id of resource group which the key pair belongs.
    tags Map<String,String>
    keyFile string
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    keyName string
    The key pair's name. It is the only in one Alicloud account.

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

    keyNamePrefix string
    keyPairName string
    publicKey string
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resourceGroupId string
    The Id of resource group which the key pair belongs.
    tags {[key: string]: string}
    key_file str
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    key_name str
    The key pair's name. It is the only in one Alicloud account.

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

    key_name_prefix str
    key_pair_name str
    public_key str
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resource_group_id str
    The Id of resource group which the key pair belongs.
    tags Mapping[str, str]
    keyFile String
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    keyName String
    The key pair's name. It is the only in one Alicloud account.

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

    keyNamePrefix String
    keyPairName String
    publicKey String
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resourceGroupId String
    The Id of resource group which the key pair belongs.
    tags Map<String>

    Outputs

    All input properties are implicitly available as output properties. Additionally, the KeyPair resource produces the following output properties:

    FingerPrint string
    Id string
    The provider-assigned unique ID for this managed resource.
    FingerPrint string
    Id string
    The provider-assigned unique ID for this managed resource.
    fingerPrint String
    id String
    The provider-assigned unique ID for this managed resource.
    fingerPrint string
    id string
    The provider-assigned unique ID for this managed resource.
    finger_print str
    id str
    The provider-assigned unique ID for this managed resource.
    fingerPrint String
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing KeyPair Resource

    Get an existing KeyPair 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?: KeyPairState, opts?: CustomResourceOptions): KeyPair
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            finger_print: Optional[str] = None,
            key_file: Optional[str] = None,
            key_name: Optional[str] = None,
            key_name_prefix: Optional[str] = None,
            key_pair_name: Optional[str] = None,
            public_key: Optional[str] = None,
            resource_group_id: Optional[str] = None,
            tags: Optional[Mapping[str, str]] = None) -> KeyPair
    func GetKeyPair(ctx *Context, name string, id IDInput, state *KeyPairState, opts ...ResourceOption) (*KeyPair, error)
    public static KeyPair Get(string name, Input<string> id, KeyPairState? state, CustomResourceOptions? opts = null)
    public static KeyPair get(String name, Output<String> id, KeyPairState 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:
    FingerPrint string
    KeyFile string
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    KeyName string
    The key pair's name. It is the only in one Alicloud account.

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

    KeyNamePrefix string
    KeyPairName string
    PublicKey string
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    ResourceGroupId string
    The Id of resource group which the key pair belongs.
    Tags Dictionary<string, string>
    FingerPrint string
    KeyFile string
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    KeyName string
    The key pair's name. It is the only in one Alicloud account.

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

    KeyNamePrefix string
    KeyPairName string
    PublicKey string
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    ResourceGroupId string
    The Id of resource group which the key pair belongs.
    Tags map[string]string
    fingerPrint String
    keyFile String
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    keyName String
    The key pair's name. It is the only in one Alicloud account.

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

    keyNamePrefix String
    keyPairName String
    publicKey String
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resourceGroupId String
    The Id of resource group which the key pair belongs.
    tags Map<String,String>
    fingerPrint string
    keyFile string
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    keyName string
    The key pair's name. It is the only in one Alicloud account.

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

    keyNamePrefix string
    keyPairName string
    publicKey string
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resourceGroupId string
    The Id of resource group which the key pair belongs.
    tags {[key: string]: string}
    finger_print str
    key_file str
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    key_name str
    The key pair's name. It is the only in one Alicloud account.

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

    key_name_prefix str
    key_pair_name str
    public_key str
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resource_group_id str
    The Id of resource group which the key pair belongs.
    tags Mapping[str, str]
    fingerPrint String
    keyFile String
    The name of file to save your new key pair's private key. Strongly suggest you to specified it when you creating key pair, otherwise, you wouldn't get its private key ever.
    keyName String
    The key pair's name. It is the only in one Alicloud account.

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

    keyNamePrefix String
    keyPairName String
    publicKey String
    You can import an existing public key and using Alicloud key pair to manage it. If this parameter is specified, resource_group_id is the key pair belongs.
    resourceGroupId String
    The Id of resource group which the key pair belongs.
    tags Map<String>

    Import

    Key pair can be imported using the name, e.g.

    $ pulumi import alicloud:ecs/keyPair:KeyPair example my_public_key
    

    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.
    alicloud logo
    Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi