-
Notifications
You must be signed in to change notification settings - Fork 65
SSH resource support #224
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
base: main
Are you sure you want to change the base?
SSH resource support #224
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,13 +45,15 @@ resource "onepassword_item" "example" { | |
|
|
||
| ### Optional | ||
|
|
||
| - `category` (String) The category of the item. One of ["login" "password" "database" "secure_note"] | ||
| - `category` (String) The category of the item. One of ["login" "password" "database" "secure_note" "ssh_key"] | ||
| - `database` (String) (Only applies to the database category) The name of the database. | ||
| - `hostname` (String) (Only applies to the database category) The address where the database can be found | ||
| - `note_value` (String, Sensitive) Secure Note value. | ||
| - `password` (String, Sensitive) Password for this item. | ||
| - `password_recipe` (Block List) The recipe used to generate a new value for a password. (see [below for nested schema](#nestedblock--password_recipe)) | ||
| - `port` (String) (Only applies to the database category) The port the database is listening on. | ||
| - `private_key` (String, Sensitive) SSH Private Key for this item. | ||
| - `public_key` (String) SSH Public Key for this item. | ||
|
Comment on lines
+55
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The connect sdk that the provider uses appears to have some issues creating ssh keys. I've noticed that in testing this fork, ssh keys I create via connect cannot be read back by op cli; when I try the cli gives this error:
This causes issues because op cli (or terraform connecting via service account rather than via connect) cannot delete/modify the resulting resource. I can't see a 'proper' way to create SSH keys via connect. Everything I try results in a record op cli cannot process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the same is true for items created via service account. The resulting item cannot be read by op cli, causing terraform destroy to fail:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have got my fork working for generating an SSH key from scratch when using a service account: i.e. in OP.create: ...
if item.Category == onepassword.SSHKey {
return op.createSSHKey(ctx, item, vaultUuid)
}
...and then a new method for ssh keys: func (op *OP) createSSHKey(ctx context.Context, item *onepassword.Item, vaultUuid string) (*onepassword.Item, error) {
args := []opArg{
p("item"), p("create"),
f("category", "SSH Key"),
f("title", item.Title),
f("vault", vaultUuid),
}
if len(item.Tags) > 0 {
args = append(args, f("tags", strings.Join(item.Tags, ",")))
}
var res *onepassword.Item
err := op.execJson(ctx, &res, nil, args...)
if err != nil {
return nil, err
}
return res, nil
}I will revisit the logic for when we use 1Password Connect on Monday, but I think it will require a patch to the connect SDK to work consistently there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've logged the following for Connect: https://github.com/1Password/onepassword-sdk-go/issues/216
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @twbrowning @volodymyrZotov, thanks for reviewing this! Unfortunately I've had to deprioritize my Terraform work for now. If you have any ideas on how to solve the issues, and properly integrate with the Connect server, then feel free to submit patches to this branch. Otherwise I will pick this up when I can return to Terraform again. |
||
| - `section` (Block List) A list of custom sections in an item (see [below for nested schema](#nestedblock--section)) | ||
| - `tags` (List of String) An array of strings of the tags assigned to the item. | ||
| - `title` (String) The title of the item. | ||
|
|
@@ -65,6 +67,7 @@ resource "onepassword_item" "example" { | |
| - `uuid` (String) The UUID of the item. Item identifiers are unique within a specific vault. | ||
|
|
||
| <a id="nestedblock--password_recipe"></a> | ||
|
|
||
| ### Nested Schema for `password_recipe` | ||
|
|
||
| Optional: | ||
|
|
@@ -74,8 +77,8 @@ Optional: | |
| - `letters` (Boolean) Use letters [a-zA-Z] when generating the password. | ||
| - `symbols` (Boolean) Use symbols [[email protected]_*] when generating the password. | ||
|
|
||
|
|
||
| <a id="nestedblock--section"></a> | ||
|
|
||
| ### Nested Schema for `section` | ||
|
|
||
| Required: | ||
|
|
@@ -91,6 +94,7 @@ Read-Only: | |
| - `id` (String) A unique identifier for the section. | ||
|
|
||
| <a id="nestedblock--section--field"></a> | ||
|
|
||
| ### Nested Schema for `section.field` | ||
|
|
||
| Required: | ||
|
|
@@ -106,6 +110,7 @@ Optional: | |
| - `value` (String, Sensitive) The value of the field. | ||
|
|
||
| <a id="nestedblock--section--field--password_recipe"></a> | ||
|
|
||
| ### Nested Schema for `section.field.password_recipe` | ||
|
|
||
| Optional: | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssh_keycategory should be added tointernal/provider/const.goas well.