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

Add key_type and key_bits to vault_ssh_secret_backend_ca #1454

Merged
merged 1 commit into from
Apr 9, 2024
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
21 changes: 20 additions & 1 deletion vault/resource_ssh_secret_backend_ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ func sshSecretBackendCAResource() *schema.Resource {
ForceNew: true,
Description: "Whether Vault should generate the signing key pair internally.",
},
"key_type": {
Type: schema.TypeString,
Default: "ssh-rsa",
Optional: true,
ForceNew: true,
Description: "Specifies the desired key type for the generated SSH CA key when `generate_signing_key` is set to `true`.",
},
"key_bits": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Description: "Specifies the desired key bits for the generated SSH CA key when `generate_signing_key` is set to `true`.",
},
"private_key": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -69,6 +82,12 @@ func sshSecretBackendCACreate(d *schema.ResourceData, meta interface{}) error {
if publicKey, ok := d.Get("public_key").(string); ok {
data["public_key"] = publicKey
}
if keyType, ok := d.Get("key_type").(string); ok {
data["key_type"] = keyType
}
if keyBits, ok := d.Get("key_bits").(int); ok {
data["key_bits"] = keyBits
}

log.Printf("[DEBUG] Writing CA information on SSH backend %q", backend)
_, err := client.Logical().Write(backend+"/config/ca", data)
Expand Down Expand Up @@ -109,7 +128,7 @@ func sshSecretBackendCARead(d *schema.ResourceData, meta interface{}) error {
d.Set("public_key", secret.Data["public_key"])
d.Set("backend", backend)

// the API doesn't return private_key and generate_signing_key
// the API doesn't return private_key, generate_signing_key, key_type, or key_bits.
// So... if they drift, they drift.

return nil
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/ssh_secret_backend_ca.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ The following arguments are supported:

* `generate_signing_key` - (Optional) Whether Vault should generate the signing key pair internally. Defaults to true

* `key_type` - (Optional) Specifies the desired key type for the generated SSH CA key when `generate_signing_key` is set to `true`.

* `key_bits` - (Optional) Specifies the desired key bits for the generated SSH CA key when `generate_signing_key` is set to `true`.

* `public_key` - (Optional) The public key part the SSH CA key pair; required if generate_signing_key is false.

* `private_key` - (Optional) The private key part the SSH CA key pair; required if generate_signing_key is false.
Expand Down
Loading