Skip to content

Commit 153947f

Browse files
authored
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
1 parent c1ada31 commit 153947f

16 files changed

Lines changed: 1257 additions & 113 deletions

File tree

docs/data-sources/key_pair.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stackit_key_pair Data Source - stackit"
4+
subcategory: ""
5+
description: |-
6+
Key pair resource schema. Must have a region specified in the provider configuration.
7+
~> 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.
8+
---
9+
10+
# stackit_key_pair (Data Source)
11+
12+
Key pair resource schema. Must have a `region` specified in the provider configuration.
13+
14+
~> 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.
15+
16+
## Example Usage
17+
18+
```terraform
19+
data "stackit_key_pair" "example" {
20+
name = "example-key-pair-name"
21+
}
22+
```
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Required
28+
29+
- `name` (String) The name of the SSH key pair.
30+
31+
### Read-Only
32+
33+
- `fingerprint` (String) The fingerprint of the public SSH key.
34+
- `id` (String) Terraform's internal resource ID. It takes the value of the key pair "`name`".
35+
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container.
36+
- `public_key` (String) A string representation of the public SSH key. E.g., `ssh-rsa <key_data>` or `ssh-ed25519 <key-data>`.

docs/data-sources/public_ip.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
page_title: "stackit_public_ip Data Source - stackit"
44
subcategory: ""
55
description: |-
6-
Volume resource schema. Must have a region specified in the provider configuration.
6+
Public IP resource schema. Must have a region specified in the provider configuration.
77
~> 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.
88
---
99

1010
# stackit_public_ip (Data Source)
1111

12-
Volume resource schema. Must have a `region` specified in the provider configuration.
12+
Public IP resource schema. Must have a `region` specified in the provider configuration.
1313

1414
~> 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.
1515

docs/resources/key_pair.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stackit_key_pair Resource - stackit"
4+
subcategory: ""
5+
description: |-
6+
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.
7+
Usage with server
8+
```terraform
9+
resource "stackitkeypair" "keypair" {
10+
name = "example-key-pair"
11+
publickey = chomp(file("path/to/idrsa.pub"))
12+
}
13+
resource "stackitserver" "example-server" {
14+
projectid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
15+
name = "example-server"
16+
bootvolume = {
17+
size = 64
18+
sourcetype = "image"
19+
sourceid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
20+
}
21+
availabilityzone = "eu01-1"
22+
machinetype = "g1.1"
23+
keypairname = "example-key-pair"
24+
}
25+
~> 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.
26+
---
27+
28+
# stackit_key_pair (Resource)
29+
30+
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.
31+
32+
33+
34+
### Usage with server
35+
```terraform
36+
resource "stackit_key_pair" "keypair" {
37+
name = "example-key-pair"
38+
public_key = chomp(file("path/to/id_rsa.pub"))
39+
}
40+
41+
resource "stackit_server" "example-server" {
42+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
43+
name = "example-server"
44+
boot_volume = {
45+
size = 64
46+
source_type = "image"
47+
source_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
48+
}
49+
availability_zone = "eu01-1"
50+
machine_type = "g1.1"
51+
keypair_name = "example-key-pair"
52+
}
53+
54+
55+
~> 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.
56+
57+
58+
59+
<!-- schema generated by tfplugindocs -->
60+
## Schema
61+
62+
### Required
63+
64+
- `name` (String) The name of the SSH key pair.
65+
- `public_key` (String) A string representation of the public SSH key. E.g., `ssh-rsa <key_data>` or `ssh-ed25519 <key-data>`.
66+
67+
### Optional
68+
69+
- `labels` (Map of String) Labels are key-value string pairs which can be attached to a resource container.
70+
71+
### Read-Only
72+
73+
- `fingerprint` (String) The fingerprint of the public SSH key.
74+
- `id` (String) Terraform's internal resource ID. It takes the value of the key pair "`name`".

0 commit comments

Comments
 (0)