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

[Question] How to configure optional-computed properties? #21278

Closed
dikhan opened this issue May 11, 2019 · 4 comments
Closed

[Question] How to configure optional-computed properties? #21278

dikhan opened this issue May 11, 2019 · 4 comments
Labels

Comments

@dikhan
Copy link

dikhan commented May 11, 2019

Hi guys,

Quick question:

What would be the best way to represent in the resource schema a property that is optional but may be computed by the API if the value is not provided by the user? Wondering if setting the property as both Optional = true AND Computed = true would be the way to go.

I see the resource schema has a Default field, that if populated will make terraform assign that value to the property if not provided as input by the user...However, if the API is already computing the value if it's not provided, why should Terraform push the value instead? That means that a change in the API to update the default value to a different one, will also require a change in the provider too.

Thanks!
Dani

@apparentlymart
Copy link
Contributor

Hi @dikhan!

Your idea is the right one: the meaning of Computed is "a value will be assigned during Create", and if you combine that with Optional then it means "if no value is given in configuration then a value will be assigned during Create".

The analogy to Default is a good way to think about it. In fact, Default is actually a special case of Computed as far as Terraform Core is concerned (the value is decided during planning rather than during apply, but the same principle applies). The Terraform SDK splits this into two separate ideas because it makes the common case of assigning constant values as defaults easier to implement.

Please note that we use GitHub issues for tracking bugs and enhancements rather than for questions. While we may be able to help with certain simple problems here it's generally better to use one of the community forums where there are far more people ready to help, whereas the GitHub issues here are generally monitored only by our few core maintainers.

@hashibot
Copy link
Contributor

Hello again!

We didn't hear back from you, so I'm going to close this in the hope that a previous response gave you the information you needed. If not, please do feel free to re-open this and leave another comment with the information my human friends requested above. Thanks!

@dikhan
Copy link
Author

dikhan commented Aug 20, 2019

Hi, sorry for the late response here. Yep, the response helped a lot, thanks!

@ghost
Copy link

ghost commented Sep 12, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants