1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. KeyPair
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

tencentcloud.KeyPair

Explore with Pulumi AI

tencentcloud logo
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

    Provides a key pair resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const foo = new tencentcloud.KeyPair("foo", {keyName: "terraform_test"});
    const foo1 = new tencentcloud.KeyPair("foo1", {
        keyName: "terraform_test",
        publicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw==",
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    foo = tencentcloud.KeyPair("foo", key_name="terraform_test")
    foo1 = tencentcloud.KeyPair("foo1",
        key_name="terraform_test",
        public_key="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw==")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := tencentcloud.NewKeyPair(ctx, "foo", &tencentcloud.KeyPairArgs{
    			KeyName: pulumi.String("terraform_test"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = tencentcloud.NewKeyPair(ctx, "foo1", &tencentcloud.KeyPairArgs{
    			KeyName:   pulumi.String("terraform_test"),
    			PublicKey: pulumi.String("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw=="),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var foo = new Tencentcloud.KeyPair("foo", new()
        {
            KeyName = "terraform_test",
        });
    
        var foo1 = new Tencentcloud.KeyPair("foo1", new()
        {
            KeyName = "terraform_test",
            PublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw==",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.KeyPair;
    import com.pulumi.tencentcloud.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 foo = new KeyPair("foo", KeyPairArgs.builder()
                .keyName("terraform_test")
                .build());
    
            var foo1 = new KeyPair("foo1", KeyPairArgs.builder()
                .keyName("terraform_test")
                .publicKey("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw==")
                .build());
    
        }
    }
    
    resources:
      foo:
        type: tencentcloud:KeyPair
        properties:
          keyName: terraform_test
      foo1:
        type: tencentcloud:KeyPair
        properties:
          keyName: terraform_test
          publicKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDjd8fTnp7Dcuj4mLaQxf9Zs/ORgUL9fQxRCNKkPgP1paTy1I513maMX126i36Lxxl3+FUB52oVbo/FgwlIfX8hyCnv8MCxqnuSDozf1CD0/wRYHcTWAtgHQHBPCC2nJtod6cVC3kB18KeV4U7zsxmwFeBIxojMOOmcOBuh7+trRw==
    

    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: KeyPairArgs,
                opts: Optional[ResourceOptions] = None)
    
    @overload
    def KeyPair(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                key_name: Optional[str] = None,
                key_pair_id: Optional[str] = None,
                project_id: Optional[float] = None,
                public_key: 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, CustomResourceOptions? opts = null)
    public KeyPair(String name, KeyPairArgs args)
    public KeyPair(String name, KeyPairArgs args, CustomResourceOptions options)
    
    type: tencentcloud: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.

    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:

    KeyName string
    The key pair's name. It is the only in one TencentCloud account.
    KeyPairId string
    ID of the resource.
    ProjectId double
    Specifys to which project the key pair belongs.
    PublicKey string
    You can import an existing public key and using TencentCloud key pair to manage it.
    Tags Dictionary<string, string>
    Tags of the key pair.
    KeyName string
    The key pair's name. It is the only in one TencentCloud account.
    KeyPairId string
    ID of the resource.
    ProjectId float64
    Specifys to which project the key pair belongs.
    PublicKey string
    You can import an existing public key and using TencentCloud key pair to manage it.
    Tags map[string]string
    Tags of the key pair.
    keyName String
    The key pair's name. It is the only in one TencentCloud account.
    keyPairId String
    ID of the resource.
    projectId Double
    Specifys to which project the key pair belongs.
    publicKey String
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags Map<String,String>
    Tags of the key pair.
    keyName string
    The key pair's name. It is the only in one TencentCloud account.
    keyPairId string
    ID of the resource.
    projectId number
    Specifys to which project the key pair belongs.
    publicKey string
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags {[key: string]: string}
    Tags of the key pair.
    key_name str
    The key pair's name. It is the only in one TencentCloud account.
    key_pair_id str
    ID of the resource.
    project_id float
    Specifys to which project the key pair belongs.
    public_key str
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags Mapping[str, str]
    Tags of the key pair.
    keyName String
    The key pair's name. It is the only in one TencentCloud account.
    keyPairId String
    ID of the resource.
    projectId Number
    Specifys to which project the key pair belongs.
    publicKey String
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags Map<String>
    Tags of the key pair.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the KeyPair 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 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,
            key_name: Optional[str] = None,
            key_pair_id: Optional[str] = None,
            project_id: Optional[float] = None,
            public_key: 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)
    resources:  _:    type: tencentcloud:KeyPair    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.
    The following state arguments are supported:
    KeyName string
    The key pair's name. It is the only in one TencentCloud account.
    KeyPairId string
    ID of the resource.
    ProjectId double
    Specifys to which project the key pair belongs.
    PublicKey string
    You can import an existing public key and using TencentCloud key pair to manage it.
    Tags Dictionary<string, string>
    Tags of the key pair.
    KeyName string
    The key pair's name. It is the only in one TencentCloud account.
    KeyPairId string
    ID of the resource.
    ProjectId float64
    Specifys to which project the key pair belongs.
    PublicKey string
    You can import an existing public key and using TencentCloud key pair to manage it.
    Tags map[string]string
    Tags of the key pair.
    keyName String
    The key pair's name. It is the only in one TencentCloud account.
    keyPairId String
    ID of the resource.
    projectId Double
    Specifys to which project the key pair belongs.
    publicKey String
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags Map<String,String>
    Tags of the key pair.
    keyName string
    The key pair's name. It is the only in one TencentCloud account.
    keyPairId string
    ID of the resource.
    projectId number
    Specifys to which project the key pair belongs.
    publicKey string
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags {[key: string]: string}
    Tags of the key pair.
    key_name str
    The key pair's name. It is the only in one TencentCloud account.
    key_pair_id str
    ID of the resource.
    project_id float
    Specifys to which project the key pair belongs.
    public_key str
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags Mapping[str, str]
    Tags of the key pair.
    keyName String
    The key pair's name. It is the only in one TencentCloud account.
    keyPairId String
    ID of the resource.
    projectId Number
    Specifys to which project the key pair belongs.
    publicKey String
    You can import an existing public key and using TencentCloud key pair to manage it.
    tags Map<String>
    Tags of the key pair.

    Import

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

    $ pulumi import tencentcloud:index/keyPair:KeyPair foo skey-17634f05
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    tencentcloud tencentcloudstack/terraform-provider-tencentcloud
    License
    Notes
    This Pulumi package is based on the tencentcloud Terraform Provider.
    tencentcloud logo
    tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack