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

Delete Vault Provider Terraform code #427

Closed
AsierArandaS opened this issue May 28, 2019 · 3 comments
Closed

Delete Vault Provider Terraform code #427

AsierArandaS opened this issue May 28, 2019 · 3 comments

Comments

@AsierArandaS
Copy link

Hi all

I'm testing Vault in my Azure test environment using terraform and it works great!!
I need to remove the vault code from my terraform code, but when I do a plan, terraform try to connect to Vault server but the code is commented because I don't want use vault in this environment. I only want to test the app to other clients, not for my test environment.

Acquiring state lock. This may take a few moments...
provider.vault.address
URL of the root of the target Vault server.

Enter a value:

Error: Error refreshing state: 1 error(s) occurred:

  • provider.vault: no vault token found

I have the code commented but I don't know if is this is sufficient

/*
provider "vault" {
address = "http://....129:8200"
skip_tls_verify = true
token = "s...Nz9J4U"

}
*/
How could I remove Vault from my terraform code and backend?

Thanks!!

@cvbarros
Copy link
Contributor

cvbarros commented May 28, 2019

You need to have different states per environment you're plan/applying.
If you want to conditionally use Vault, using the same code/configuration depending on the environment, I suggest you use modules to segment and enable/disable them based on the environment.

As for fixing your current situation, you can manually edit the state or use Terraform State Command

Edit: If you have no resources in your state named vault_*, you can comment out the provider block and then it won't be needed. If you still have these resources in your state, Terraform will try to initialise the provider even if it's commented in code.

@diogodias24
Copy link

diogodias24 commented Oct 21, 2019

Same here.
Even if I remove him from code and from tfstate, he don't disappear.
Like everytime I do the rm command, he removes again and again. Real problem here?

terraform state rm provider.vault 1 items removed.
Item removal successful.

EDIT: Figured it out

You need to go to your tfstate , search for vault resources, and delete them for aws , or from state itself , or from both ;) :

terraform state rm resource.vault.example

After all resources are removed, terraform init won't download anymore vault provider.
See data 's as weel, because if you have any data on state file that have's vault provider, terraform will download that provider too.
Thanks

@fairclothjm
Copy link
Contributor

Closing stale issue

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

No branches or pull requests

4 participants