-
Notifications
You must be signed in to change notification settings - Fork 101
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 import for CSI volumes and job #359
Conversation
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.
Running the terraform import
command seems to work fine for me here:
$ terraform import nomad_job.httpd httpd
nomad_job.httpd: Importing from ID "httpd"...
nomad_job.httpd: Import prepared!
Prepared nomad_job for import
nomad_job.httpd: Refreshing state... [id=httpd]
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.
But using an import does not, and I'm not sure if there's something extra we need to implement to make it work. Using the following Terraform config:
provider "nomad" {
address = "http://localhost:4646"
}
import {
to = nomad_job.httpd
id = "httpd"
}
resource "nomad_job" "httpd" {
}
I get the following error:
$ terraform plan
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│ - hashicorp/nomad in /home/tim/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying
│ changes may cause the state to become incompatible with published releases.
╵
╷
│ Error: Missing required argument
│
│ on main.tf line 10, in resource "nomad_job" "httpd":
│ 10: resource "nomad_job" "httpd" {
│
│ The argument "jobspec" is required, but no definition was found.
╵
Ah yes, you need to add the provider "nomad" {
address = "http://localhost:4646"
}
import {
to = nomad_job.httpd
id = "httpd"
}
resource "nomad_job" "httpd" {
jobspec = file("${path.module}/httpd.nomad.hcl")
} |
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.
LGTM!
Oh... I guess that makes sense because the jobspec is external to the Terraform module, rather than being a set of attributes on the resource. |
Yeah, after importing your config needs to match your state to prevent values from being lost in the next apply. There is experimental work on auto-generating configuration on import (https://developer.hashicorp.com/terraform/language/import/generating-configuration) but I doubt it would work for |
No changelog since this is a new resource.Highjacking the PR to also add import support for jobs since I noticed that these are the last resources missing import.
Closes #137