1. Packages
  2. stackit
  3. API Docs
  4. KeyPair
Viewing docs for stackit v0.0.4
published on Friday, Feb 20, 2026 by stackitcloud
stackit logo
Viewing docs for stackit v0.0.4
published on Friday, Feb 20, 2026 by stackitcloud

    Key pair resource schema. Must have a region specified in the provider configuration. Allows uploading an SSH public key to be used for server authentication.

    Example Usage

    # Create a key pair
    resource "stackit_key_pair" "keypair" {
      name       = "example-key-pair"
      public_key = chomp(file("path/to/id_rsa.pub"))
    }
    
    # Only use the import statement, if you want to import an existing key pair
    import {
      to = stackit_key_pair.import-example
      id = var.keypair_name
    }
    

    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,
                public_key: Optional[str] = None,
                labels: Optional[Mapping[str, str]] = None,
                name: Optional[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: stackit: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 keyPairResource = new Stackit.KeyPair("keyPairResource", new()
    {
        PublicKey = "string",
        Labels = 
        {
            { "string", "string" },
        },
        Name = "string",
    });
    
    example, err := stackit.NewKeyPair(ctx, "keyPairResource", &stackit.KeyPairArgs{
    	PublicKey: pulumi.String("string"),
    	Labels: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var keyPairResource = new KeyPair("keyPairResource", KeyPairArgs.builder()
        .publicKey("string")
        .labels(Map.of("string", "string"))
        .name("string")
        .build());
    
    key_pair_resource = stackit.KeyPair("keyPairResource",
        public_key="string",
        labels={
            "string": "string",
        },
        name="string")
    
    const keyPairResource = new stackit.KeyPair("keyPairResource", {
        publicKey: "string",
        labels: {
            string: "string",
        },
        name: "string",
    });
    
    type: stackit:KeyPair
    properties:
        labels:
            string: string
        name: string
        publicKey: 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:

    PublicKey string
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    Labels Dictionary<string, string>
    Labels are key-value string pairs which can be attached to a resource container.
    Name string
    The name of the SSH key pair.
    PublicKey string
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    Labels map[string]string
    Labels are key-value string pairs which can be attached to a resource container.
    Name string
    The name of the SSH key pair.
    publicKey String
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    labels Map<String,String>
    Labels are key-value string pairs which can be attached to a resource container.
    name String
    The name of the SSH key pair.
    publicKey string
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    labels {[key: string]: string}
    Labels are key-value string pairs which can be attached to a resource container.
    name string
    The name of the SSH key pair.
    public_key str
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    labels Mapping[str, str]
    Labels are key-value string pairs which can be attached to a resource container.
    name str
    The name of the SSH key pair.
    publicKey String
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    labels Map<String>
    Labels are key-value string pairs which can be attached to a resource container.
    name String
    The name of the SSH key pair.

    Outputs

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

    Fingerprint string
    The fingerprint of the public SSH key.
    Id string
    The provider-assigned unique ID for this managed resource.
    Fingerprint string
    The fingerprint of the public SSH key.
    Id string
    The provider-assigned unique ID for this managed resource.
    fingerprint String
    The fingerprint of the public SSH key.
    id String
    The provider-assigned unique ID for this managed resource.
    fingerprint string
    The fingerprint of the public SSH key.
    id string
    The provider-assigned unique ID for this managed resource.
    fingerprint str
    The fingerprint of the public SSH key.
    id str
    The provider-assigned unique ID for this managed resource.
    fingerprint String
    The fingerprint of the public SSH key.
    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,
            fingerprint: Optional[str] = None,
            labels: Optional[Mapping[str, str]] = None,
            name: Optional[str] = None,
            public_key: Optional[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: stackit: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:
    Fingerprint string
    The fingerprint of the public SSH key.
    Labels Dictionary<string, string>
    Labels are key-value string pairs which can be attached to a resource container.
    Name string
    The name of the SSH key pair.
    PublicKey string
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    Fingerprint string
    The fingerprint of the public SSH key.
    Labels map[string]string
    Labels are key-value string pairs which can be attached to a resource container.
    Name string
    The name of the SSH key pair.
    PublicKey string
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    fingerprint String
    The fingerprint of the public SSH key.
    labels Map<String,String>
    Labels are key-value string pairs which can be attached to a resource container.
    name String
    The name of the SSH key pair.
    publicKey String
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    fingerprint string
    The fingerprint of the public SSH key.
    labels {[key: string]: string}
    Labels are key-value string pairs which can be attached to a resource container.
    name string
    The name of the SSH key pair.
    publicKey string
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    fingerprint str
    The fingerprint of the public SSH key.
    labels Mapping[str, str]
    Labels are key-value string pairs which can be attached to a resource container.
    name str
    The name of the SSH key pair.
    public_key str
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.
    fingerprint String
    The fingerprint of the public SSH key.
    labels Map<String>
    Labels are key-value string pairs which can be attached to a resource container.
    name String
    The name of the SSH key pair.
    publicKey String
    A string representation of the public SSH key. E.g., ssh-rsa <key_data> or ssh-ed25519 <key-data>.

    Package Details

    Repository
    stackit stackitcloud/pulumi-stackit
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the stackit Terraform Provider.
    stackit logo
    Viewing docs for stackit v0.0.4
    published on Friday, Feb 20, 2026 by stackitcloud
      Try Pulumi Cloud free. Your team will thank you.