-
Notifications
You must be signed in to change notification settings - Fork 409
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
[ISSUE] User name skipped when importing a user #471
Comments
I was able to reproduce this issue, trying to find the reason for it... |
For anyone looking into this @alexott the reason is in The lines there cause the user_name during import to be disgarded. Quick way to reproduce via building binary is to add this log statement or switch logging to print out the traces:
Unfortunately i dont know a quick fix for this yet. |
hmm one way we can try to approach this is to change common_resource.go rather than touching changing logic in reflect_resource. we can change: Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
}, to Importer: &schema.ResourceImporter{
StateContext: func(ctx context.Context, d *schema.ResourceData, m interface{}) (data []*schema.ResourceData, e error) {
d.Id()
newCtx := context.WithValue(ctx, "importing", true)
err := r.Read(newCtx, d, m.(*common.DatabricksClient))
return []*schema.ResourceData{d}, err
},
}, This will allow the ctx.WithValue("importing") to yield a true. This can be used in the logic statement that during an import do not reject server value. The con of this is that we would need to touch reflect_resource (allow for ctx to pass through), common_resource(new importing) and this also causes two get requests to be called for every import where as importpassthrough does not. Alternatively the least amount of code change option is to make username in UserName string `json:"user_name,omitempty" tf:"computed"` |
This issue is not just for user_name but for a lot of the fields that are not computed are imported. We should add these to the acceptance test cases to the resources that support imports: {
ResourceName: "<resource_type>.<resource_id>",
ImportState: true,
ImportStateVerify: true,
} Resolving the issue should pass the import test cases. This only helps identify issues with resources but in terms of a wholistic fix for all resources any ideas @nfx. |
@stikkireddy the approach here is the correct one, but we just need to verify it working. |
Seems like while importing users, it skips over fields like user name. I think it's a similar issue mentioned in #401
Kind of important since the user name is skipped, terraform tries to recreate the resource even after importing.
Terraform Version
Terraform v0.13.6
Affected Resource(s)
Terraform Configuration Files
Debug Output
Expected Behavior
Should import user fields
Actual Behavior
Seems like its skipping fields like user_name. as seen in the logs above. Eg. state file:
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform import databricks_user.xxx_yyy "2222222"
The text was updated successfully, but these errors were encountered: