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

resource_token tries to renew access token instead of resource token #422

Closed
peric opened this issue May 21, 2019 · 0 comments · Fixed by #423
Closed

resource_token tries to renew access token instead of resource token #422

peric opened this issue May 21, 2019 · 0 comments · Fixed by #423

Comments

@peric
Copy link

peric commented May 21, 2019

In our private project, we use resource_token inside a module to setup a custom token for each of our projects (aka AWS accounts). At the moment, we have 15 projects, which means 15 different tokens.

To set up those projects, we use a parent token which has permission to create child tokens.

We use renewable = true to make tokens renewable, but code from this project does not work for us because it tries to renew "access token" instead of "resource tokens".

Maybe I am missing something, but in my opinion solution should work as described below. I will also provide a PR with that should be correct, at least in my opinion.

Actual Behavior

tokenRead function of resource_token resource currently (in a nutshell) works like:

  • LookupAccessor function is called with received token accessor
  • if needed, token renewal will be performed. But, instead on the received token, RenewSelf function will be called, which will try to perform renewal on a token which is currently authenticated

https://github.com/terraform-providers/terraform-provider-vault/blob/master/vault/resource_token.go#L263

Expected Behavior

tokenRead function of resource_token should work like:

  • LookupAccessor function should be called with received token accessor
  • if needed, token renewal will be performed. Renew function should be called instead of RenewSelf. Resource token id should be provided to the Renew function.

Terraform Version

Terraform v0.11.13

Affected Resource(s)

Please list the resources as a list, for example:

  • resource_token

Terraform Configuration Files

resource "vault_token" "app_token" {
  // 180 days
  ttl              = "15552000"
  explicit_max_ttl = "15552000"

  // 90 days
  renewable       = true
  renew_min_lease = "7776000"

  no_parent = true

  policies = [
    "${vault_policy.app_policy.name}",
  ]

  display_name = "${local.postfix}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant