Skip to content

Commit

Permalink
Refactor SSH refactor (IBM-Cloud#5474)
Browse files Browse the repository at this point in the history
* Refactor PI Key

* Fix minor syntax issues

---------

Co-authored-by: michaelkad <[email protected]>
  • Loading branch information
ismirlia and michaelkad authored Jul 12, 2024
1 parent d41a95b commit 2a53ac3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
1 change: 0 additions & 1 deletion ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ const (
Attr_Key = "key"
Attr_KeyCreationDate = "creation_date"
Attr_KeyID = "key_id"
Attr_KeyName = "name"
Attr_Keys = "keys"
Attr_Language = "language"
Attr_LastUpdateDate = "last_update_date"
Expand Down
6 changes: 3 additions & 3 deletions ibm/service/power/resource_ibm_pi_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func ResourceIBMPIKey() *schema.Resource {
Description: "Date of SSH Key creation.",
Type: schema.TypeString,
},
Attr_KeyName: {
Attr_Name: {
Computed: true,
Description: "User defined name for the SSH key.",
Type: schema.TypeString,
Expand Down Expand Up @@ -121,9 +121,9 @@ func resourceIBMPIKeyRead(ctx context.Context, d *schema.ResourceData, meta inte
}

// set attributes
d.Set(Attr_KeyName, sshkeydata.Name)
d.Set(Attr_Key, sshkeydata.SSHKey)
d.Set(Attr_CreationDate, sshkeydata.CreationDate.String())
d.Set(Attr_Key, sshkeydata.SSHKey)
d.Set(Attr_Name, sshkeydata.Name)

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/power/resource_ibm_pi_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ func testAccCheckIBMPIKeyConfig(publicKey, name string) string {
pi_cloud_instance_id = "%s"
pi_key_name = "%s"
pi_ssh_key = "%s"
}`, acc.Pi_cloud_instance_id, name, publicKey)
}`, acc.Pi_cloud_instance_id, name, publicKey)
}
25 changes: 17 additions & 8 deletions website/docs/r/pi_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ description: |-
---

# ibm_pi_key

Create, update, or delete an SSH key for your Power Systems Virtual Server instance. The SSH key is used to access the instance after it is created. For more information, about SSH keys in Power Virtual Server, see [getting started with IBM Power Systems Virtual Servers](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-getting-started).

## Example usage

The following example enables you to create a SSH key to be used during creation of a power virtual server instance:

```terraform
Expand All @@ -20,13 +22,15 @@ resource "ibm_pi_key" "testacc_sshkey" {
}
```

**Notes**
### Notes

- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints.
- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows:
- `region` - `lon`
- `zone` - `lon04`

Example usage:

```terraform
provider "ibm" {
region = "lon"
Expand All @@ -35,30 +39,35 @@ Example usage:
```

## Timeouts

ibm_pi_key provides the following [timeouts](https://www.terraform.io/docs/language/resources/syntax.html) configuration options:

- **create** - (Default 60 minutes) Used for creating a SSH key.
- **delete** - (Default 60 minutes) Used for deleting a SSH key.

## Argument reference
Review the argument references that you can specify for your resource.

Review the argument references that you can specify for your resource.

- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account.
- `pi_key_name` - (Required, String) User defined name for the SSH key.
- `pi_ssh_key` - (Required, String) SSH RSA key.
- `pi_key_name` - (Required, String) User defined name for the SSH key.
- `pi_ssh_key` - (Required, String) SSH RSA key.

## Attribute reference

In addition to all argument reference list, you can access the following attribute reference after your resource is created.

- `creation_date` - (String) Date of SSH Key creation.
- `creation_date` - (String) Date of SSH Key creation.
- `id` - (String) The unique identifier of the key. The ID is composed of `<pi_cloud_instance_id>/<pi_key_name>`.
- `name` - (String) User defined name for the SSH key.
- `ssh_key` - (String) SSH RSA key.

## Import

The `ibm_pi_key` resource can be imported by using `pi_cloud_instance_id` and `pi_key_name`.

**Example**
### Example

```bash
terraform import ibm_pi_key.example d7bec597-4726-451f-8a63-e62e6f19c32c/mykey
```
$ terraform import ibm_pi_key.example d7bec597-4726-451f-8a63-e62e6f19c32c/mykey
```

0 comments on commit 2a53ac3

Please sign in to comment.