-
Notifications
You must be signed in to change notification settings - Fork 553
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
Allow vault_ldap_auth resources to be imported #387
Merged
tyrannosaurus-becks
merged 4 commits into
hashicorp:master
from
lucymhdavies:import-ldap-resources
Apr 29, 2019
Merged
Allow vault_ldap_auth resources to be imported #387
tyrannosaurus-becks
merged 4 commits into
hashicorp:master
from
lucymhdavies:import-ldap-resources
Apr 29, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes hashicorp#383 ``` terraform import -allow-missing-config vault_ldap_auth_backend_group.foo auth/ldap/groups/foo vault_ldap_auth_backend_group.foo: Importing from ID "auth/ldap/groups/foo"... vault_ldap_auth_backend_group.foo: Import complete! Imported vault_ldap_auth_backend_group (ID: auth/ldap/groups/foo) vault_ldap_auth_backend_group.foo: Refreshing state... (ID: auth/ldap/groups/foo) Import successful! The resources that were imported are shown above. These resources are now in your Terraform state and will henceforth be managed by Terraform. ``` I've not updated any docs yet, and I've only manually tested `vault_ldap_auth_backend_group` by hand so far, so this still needs docs written and tests added.
Turns out, there's more to it than appeared to be the case from my previous commit. I've not run the full test suite, but only tested the resources I have modified as follows ``` docker run -it --rm -p 8200:8200 vault server -dev -dev-root-token-id="root" VAULT_ADDR=http://0.0.0.0:8200 VAULT_TOKEN=root TF_ACC=1 go test -v --run TestLDAPAuthBackendGroup github.com/terraform-providers/terraform-provider-vault/vault ``` Currently they fail due to, for example: ``` === RUN TestLDAPAuthBackendGroup_import --- FAIL: TestLDAPAuthBackendGroup_import (0.12s) testing.go:538: Step 1 error: ImportStateVerify attributes not equivalent. Difference is shown below. Top is actual, bottom is expected. (map[string]string) { } (map[string]string) (len=2) { (string) (len=7) "backend": (string) (len=39) "tf-test-ldap-backend-392924653340835300", (string) (len=9) "groupname": (string) (len=38) "tf-test-ldap-group-3866433073382041940" } ```
I took inspiration from how AppRoles work, borrowing a lot of the code from there. ``` $ VAULT_ADDR=http://0.0.0.0:8200 VAULT_TOKEN=root TF_ACC=1 go test -v --run TestLDAPAuthBackend github.com/terraform-providers/terraform-provider-vault/vault === RUN TestLDAPAuthBackendGroup_import --- PASS: TestLDAPAuthBackendGroup_import (0.11s) === RUN TestLDAPAuthBackendGroup_basic --- PASS: TestLDAPAuthBackendGroup_basic (0.09s) === RUN TestLDAPAuthBackend_import --- PASS: TestLDAPAuthBackend_import (0.08s) === RUN TestLDAPAuthBackend_basic --- PASS: TestLDAPAuthBackend_basic (0.07s) === RUN TestLDAPAuthBackendUser_import --- PASS: TestLDAPAuthBackendUser_import (0.08s) === RUN TestLDAPAuthBackendUser_basic --- PASS: TestLDAPAuthBackendUser_basic (0.08s) PASS ok github.com/terraform-providers/terraform-provider-vault/vault 0.529s ``` Needed to modify `TestLDAPAuthBackend_import` slightly, as I forgot that `bindpass` isn't returned from the Vault API
lucymhdavies
force-pushed
the
import-ldap-resources
branch
from
April 6, 2019 20:48
fe02070
to
612577b
Compare
tyrannosaurus-becks
approved these changes
Apr 29, 2019
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.
@lucymhdavies fantastic! Thank you!
dandandy
pushed a commit
to dandandy/terraform-provider-vault
that referenced
this pull request
Jun 17, 2021
Allow vault_ldap_auth resources to be imported
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #383
Having pushed this, I now see that the
ldap_auth_backend
part of this may become redundant, given #273