terraform-provider-stackitp.../docs/resources/key_pair.md
João Palet 153947fd7b
Implement key pair resource (#578)
* feat: Implement key pair resource

* feat: Implement acceptance test

* fix: Minor fixes to server and public IP resources

* fix: Lint fixes

* fix: Generalize description

* feat: Update examples to read key from file; Add datasource example

* fix: Fix field descriptions

* fix: Fix example

* feat: Add link to key pair resource in server example

* feat: Add links to key pair resource in other examples
2024-11-05 09:50:55 +00:00

2.6 KiB

page_title subcategory description
stackit_key_pair Resource - stackit 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. Usage with server ```terraform resource "stackitkeypair" "keypair" { name = "example-key-pair" publickey = chomp(file("path/to/idrsa.pub")) } resource "stackitserver" "example-server" { projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "example-server" bootvolume = { size = 64 sourcetype = "image" sourceid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } availabilityzone = "eu01-1" machinetype = "g1.1" keypairname = "example-key-pair" } ~> This resource is in beta and may be subject to breaking changes in the future. Use with caution. See our guide https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/guides/opting_into_beta_resources for how to opt-in to use beta resources.

stackit_key_pair (Resource)

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.

Usage with server

resource "stackit_key_pair" "keypair" {
  name       = "example-key-pair"
  public_key = chomp(file("path/to/id_rsa.pub"))
}

resource "stackit_server" "example-server" {
  project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  name       = "example-server"
  boot_volume = {
    size        = 64
    source_type = "image"
    source_id   = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }
  availability_zone = "eu01-1"
  machine_type      = "g1.1"
  keypair_name      = "example-key-pair"
}


~> This resource is in beta and may be subject to breaking changes in the future. Use with caution. See our [guide](https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/guides/opting_into_beta_resources) for how to opt-in to use beta resources.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The name of the SSH key pair.
- `public_key` (String) A string representation of the public SSH key. E.g., `ssh-rsa <key_data>` or `ssh-ed25519 <key-data>`.

### Optional

- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container.

### Read-Only

- `fingerprint` (String) The fingerprint of the public SSH key.
- `id` (String) Terraform's internal resource ID. It takes the value of the key pair "`name`".