Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update docs to clarify that the IDs in user_ssh_key_ids are user IDs #322

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions docs/resources/equinix_metal_device.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,8 @@ API auth token in the top of the page and see JSON from the API response.
[Device plans API docs](https://metal.equinix.com/developers/api/plans), set your auth token in the
top of the page and see JSON from the API response.
* `project_id` - (Required) The ID of the project in which to create the device
* `project_ssh_key_ids` - (Optional) Array of IDs of the project SSH keys which should be added to the device.
If you omit this, SSH keys of all the members of the parent project will be added to the device. If
you specify this array, only the listed project SSH keys will be added. Project SSH keys can be
created with the [equinix_metal_project_ssh_key](equinix_metal_project_ssh_key.md) resource.
* `user_ssh_key_ids` - (Optional) Array of IDs of the user SSH keys which should be added to the device. If you omit this, SSH keys of all the members of the parent project will be added to the device. If you specify this array, only the listed user SSH keys (and any project_ssh_key_ids) will be added. User SSH keys can be created with the [equinix_metal_ssh_key](equinix_metal_ssh_key.md) resource
* `project_ssh_key_ids` - (Optional) Array of IDs of the project SSH keys which should be added to the device. If you specify this array, only the listed project SSH keys (and any SSH keys for the users specified in user_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. Project SSH keys can be created with the [equinix_metal_project_ssh_key](equinix_metal_project_ssh_key.md) resource.
* `user_ssh_key_ids` - (Optional) Array of IDs of the users whose SSH keys should be added to the device. If you specify this array, only the listed users' SSH keys (and any project SSH keys specified in project_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. User SSH keys can be created with the [equinix_metal_ssh_key](equinix_metal_ssh_key.md) resource.
* `reinstall` - (Optional) Whether the device should be reinstalled instead of destroyed when
modifying user_data, custom_data, or operating system. See [Reinstall](#reinstall) below for more
details.
Expand Down
4 changes: 2 additions & 2 deletions equinix/resource_metal_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ func resourceMetalDevice() *schema.Resource {
},
"project_ssh_key_ids": {
Type: schema.TypeList,
Description: "Array of IDs of the project SSH keys which should be added to the device. If you omit this, SSH keys of all the members of the parent project will be added to the device. If you specify this array, only the listed project SSH keys (and any user_ssh_key_ids) will be added. Project SSH keys can be created with the [equinix_metal_project_ssh_key](equinix_metal_project_ssh_key.md) resource",
Description: "Array of IDs of the project SSH keys which should be added to the device. If you specify this array, only the listed project SSH keys (and any SSH keys for the users specified in user_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. Project SSH keys can be created with the [equinix_metal_project_ssh_key](equinix_metal_project_ssh_key.md) resource",
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"user_ssh_key_ids": {
Type: schema.TypeList,
Description: "Array of IDs of the user SSH keys which should be added to the device. If you omit this, SSH keys of all the members of the parent project will be added to the device. If you specify this array, only the listed user SSH keys (and any project_ssh_key_ids) will be added. User SSH keys can be created with the [equinix_metal_ssh_key](equinix_metal_ssh_key.md) resource",
Description: "Array of IDs of the users whose SSH keys should be added to the device. If you specify this array, only the listed users' SSH keys (and any project SSH keys specified in project_ssh_key_ids) will be added. If no SSH keys are specified (both user_ssh_keys_ids and project_ssh_key_ids are empty lists or omitted), all parent project keys, parent project members keys and organization members keys will be included. User SSH keys can be created with the [equinix_metal_ssh_key](equinix_metal_ssh_key.md) resource",
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Expand Down
16 changes: 13 additions & 3 deletions equinix/resource_metal_device_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,18 @@ func TestAccMetalDevice_sshConfig(t *testing.T) {
{
Config: testAccMetalDeviceConfig_ssh_key(rs, userSSHKey, projSSHKey),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
r, "ssh_key_ids.#", "2"),
resource.TestCheckTypeSetElemAttrPair(
r,
"ssh_key_ids.*",
"equinix_metal_ssh_key.test",
"id",
),
resource.TestCheckTypeSetElemAttrPair(
r,
"ssh_key_ids.*",
"equinix_metal_project_ssh_key.test",
"id",
),
),
},
},
Expand Down Expand Up @@ -906,7 +916,7 @@ resource "equinix_metal_device" "test" {
operating_system = local.os
billing_cycle = "hourly"
project_id = equinix_metal_project.test.id
user_ssh_key_ids = [equinix_metal_ssh_key.test.id]
user_ssh_key_ids = [equinix_metal_ssh_key.test.owner_id]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the 422 error from the API, but the test is currently checking that the device has 2 SSH keys, and that is an invalid expectation. It has every SSH key for the users specified in user_ssh_key_ids plus the 1 project SSH key specified in project_ssh_key_ids. I'm not really sure how to resolve this in a reliable way; can we instead check that the device SSH keys include the project and user SSH keys that were created as part of the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test has been updated to confirm that the ssh_key_ids for the device include the IDs of the SSH keys that were created in the test: a3e2156#diff-b5bc3c33d7df2c76175fac51f0b7b4a5d4e2fd0268430d3b28091961885d775fR193-R204

project_ssh_key_ids = [equinix_metal_project_ssh_key.test.id]

lifecycle {
Expand Down