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 importer to resources #137

Closed
7 tasks done
lgfa29 opened this issue Aug 6, 2020 · 5 comments · Fixed by #359
Closed
7 tasks done

Add importer to resources #137

lgfa29 opened this issue Aug 6, 2020 · 5 comments · Fixed by #359

Comments

@lgfa29
Copy link
Contributor

lgfa29 commented Aug 6, 2020

Terraform allows importing existing resources into a state using the terraform import command. In order to support this functionality resources must implement the functionalities described in this guide.

It may not be possible to add Importers to all resources, but we should try adding them whenever possible.

Here's a list of the current resources, we can check off when an importer is implemented or deemed not possible.

  • nomad_acl_policy
  • nomad_acl_token
  • nomad_job
  • nomad_namespace
  • nomad_quota_specification
  • nomad_sentinel_policy
  • nomad_volume
@evandam
Copy link

evandam commented Mar 9, 2022

Hey @lgfa29, sorry to bump an ancient issue, but do you think this would be possible at some point? I was considering switching some custom scripts and configuration management to use the Nomad provider but being able to import resources would be pretty important in getting started.

ACL policies, tokens, and namespaces would probably be at the top of our list for priority. I wish I could attempt this but I don't write Go 😅

@lgfa29
Copy link
Contributor Author

lgfa29 commented Mar 25, 2022

It's been a while huh 😞

We currently don't have it a date to get this work in, but I also just realized that the list is wrong 😅

I probably just listed all resources we had at the time without checking, but most of them are actually already importable, including the ones you listed.

provider "nomad" {
  address = "http://localhost:4646"
}

resource "nomad_acl_token" "bootstrap" {
  name   = "Bootstrap Token"
  type   = "management"
  global = true
}

resource "nomad_acl_policy" "test" {
  name      = "test"
  rules_hcl = file("${path.module}/policy.hcl")
}

resource "nomad_namespace" "dev" {
  name = "dev"
}
$ terraform import nomad_namespace.dev dev
nomad_namespace.dev: Importing from ID "dev"...
nomad_namespace.dev: Import prepared!
  Prepared nomad_namespace for import
nomad_namespace.dev: Refreshing state... [id=dev]

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.

$ terraform import nomad_acl_policy.test test
nomad_acl_policy.test: Importing from ID "test"...
nomad_acl_policy.test: Import prepared!
  Prepared nomad_acl_policy for import
nomad_acl_policy.test: Refreshing state... [id=test]

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.

$ terraform import nomad_acl_token.bootstrap 695bff24-5be9-1bfb-4a6b-54883ed61cbe
nomad_acl_token.bootstrap: Importing from ID "695bff24-5be9-1bfb-4a6b-54883ed61cbe"...
nomad_acl_token.bootstrap: Import prepared!
  Prepared nomad_acl_token for import
nomad_acl_token.bootstrap: Refreshing state... [id=695bff24-5be9-1bfb-4a6b-54883ed61cbe]

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.

$ terraform state list
nomad_acl_policy.test
nomad_acl_token.bootstrap
nomad_namespace.dev

Did you get an error when trying to import any of them?

@evandam
Copy link

evandam commented Mar 26, 2022

Oh that's great to see! No to be honest I didn't even try since it seemed things indicated it wasn't supported and undocumented 😅

Thank you for looking into it!

@tristanmorgan
Copy link
Member

can the new nomad_csi_volume be added to the import list please?

Error: resource nomad_csi_volume doesn't support import

@lgfa29
Copy link
Contributor Author

lgfa29 commented Jul 26, 2023

Ah good point @tristanmorgan. Added in #359 which should close this issue 🙂

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

Successfully merging a pull request may close this issue.

3 participants