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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new allowed_user_key_config field #1413

Merged
merged 5 commits into from Apr 14, 2022

Conversation

benashz
Copy link
Contributor

@benashz benashz commented Apr 14, 2022

This fix introduces a new configuration block for the
ssh_secret_backend_role resource, which supports the new vault-1.10
updates to the allowed_user_key_lengths parameter. The new config block
is meant to supersede the current allowed_user_key_lengths provider
field.

Example role config:

resource "vault_ssh_secret_backend_role" "demo" {
  name    = "role1"
  backend = vault_mount.demo.path

  allowed_user_key_config {
    type    = "rsa"
    lengths = [2048, 4096]
  }

  allowed_user_key_config {
    type    = "dss"
    lengths = [2048, 4096]
  }
}

Community Note

  • Please vote on this pull request by adding a 馃憤 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:


Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

This fix introduces a new configuration block for the
ssh_secret_backend_role resource, which supports the new vault-1.10
updates to the allowed_user_key_lengths parameter. The new config block
is meant to supersede the current allowed_user_key_lengths provider
field.

Example role config:
resource "vault_ssh_secret_backend_role" "demo" {
  name    = "role1"
  backend = vault_mount.demo.path

  allowed_user_key_config {
    type    = "rsa"
    lengths = [2048, 4096]
  }

  allowed_user_key_config {
    type    = "dss"
    lengths = [2048, 4096]
  }
}
@benashz benashz changed the title Add new allowed_use_key_config field Add new allowed_user_key_config field Apr 14, 2022
Copy link
Contributor

@vinay-gopalan vinay-gopalan left a comment

Choose a reason for hiding this comment

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

Looking great! A few comments/questions

log.Printf("[DEBUG] Writing role %q on SSH backend %q", name, backend)
_, err := client.Logical().Write(path, data)
if err != nil {
return fmt.Errorf("error writing role %q for backend %q: %s", name, backend, err)
// in the case where vault does not support a list of key lengths,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch! This error case had completely slipped my mind 馃槄

return err
}

newField := "allowed_user_key_lengths"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be allowed_user_key_config instead?

v[keyType] = l
}

return d.Set(newField, v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is in the case the user set the legacyField in the TF config, should we be setting legacyField to v in the TF state instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, will update per your other comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f724d6a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in affd6a1

Copy link
Contributor

@vinay-gopalan vinay-gopalan left a comment

Choose a reason for hiding this comment

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

LGTM!

@benashz benashz merged commit 28ae26d into main Apr 14, 2022
marcboudreau pushed a commit to marcboudreau/terraform-provider-vault that referenced this pull request Nov 6, 2022
This fix introduces a new configuration block for the
ssh_secret_backend_role resource, which supports the new vault-1.10
updates to the allowed_user_key_lengths parameter. The new config block
is meant to supersede the current allowed_user_key_lengths provider
field.

Example role config:
resource "vault_ssh_secret_backend_role" "demo" {
  name    = "role1"
  backend = vault_mount.demo.path

  allowed_user_key_config {
    type    = "rsa"
    lengths = [2048, 4096]
  }

  allowed_user_key_config {
    type    = "dss"
    lengths = [2048, 4096]
  }
}

* Update docs

* Complete the field name refactoring

* Set the correct field in the legacy case

* Add changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants