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

Resource "Create" should read from plan, not config? #32

Closed
jaygorrell opened this issue Apr 7, 2022 · 2 comments
Closed

Resource "Create" should read from plan, not config? #32

jaygorrell opened this issue Apr 7, 2022 · 2 comments

Comments

@jaygorrell
Copy link

jaygorrell commented Apr 7, 2022

I could be mistaken on this, but the documentation and hashicups all recommend reading from the plan for create.

However, this scaffolding is configured to read from config:

edit: As an aside, I'm not super clear on when you would actually read directly from config outside of a data source.

@project0
Copy link

Hmm, i stumbled across this as well and i am actually unsure what is the difference. At least documentation is not clear here.
While testing a bit, it seems that Plan may contain unknown values. Config did seem to contain the final values.

This discussion seems related: hashicorp/terraform-plugin-framework#191 (comment)

Nevertheless, some clarification would be great.

@bflad
Copy link
Member

bflad commented Oct 4, 2022

Hi @jaygorrell 👋 Thank you for raising this.

Indeed, the general recommendation for the Create method is to access the plan instead of configuration. The following documentation and code should reflect this now:

https://www.terraform.io/plugin/framework/resources#create

https://github.com/hashicorp/terraform-provider-hashicups-pf/blob/12e9150e4df62eb6f86dd074936f2c6155865ce5/hashicups/order_resource.go#L143

resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)

If there are other locations which reference req.Config during Create without any comment clarification, please reach out and we'll get those updated.

@bflad bflad closed this as completed Oct 4, 2022
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

3 participants