hashicorp / hashicorp/terraform-plugin-sdk

Allow defining relationships in config schemas

Open
#54 12 comments 0 reactions 0 assignees View on GitHub
enhancement ui upstream-protocol upstream-terraform
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

Given the following piece of code in [`helper/schema/schema.go`](https://github.com/hashicorp/terraform/blob/e97b4803d678cb9154d377b49a968408bca422e6/helper/schema/schema.go#L344-399)

``` go
func (m schemaMap) Input(
input terraform.UIInput,
c *terraform.ResourceConfig) (*terraform.ResourceConfig, error) {
keys := make([]string, 0, len(m))
for k, _ := range m {
keys = append(keys, k)
}
sort.Strings(keys)

for _, k := range keys {
...
```

all config options are sorted alphabetically and treated independently in the prompt.
I can imagine cases where I would like the user to enter some config options first and eventually not ask for some other options based on the entered data.

Example?
Imagine following AWS provider config:
- `credentials_provider` (`detect | iam | env | static`)
- `credentials_file_path`
- `credentials_file_profile_name`
- `access_key`
- `secret_key`
- `security_token`

It is obvious that:
1. It would be annoying to ask user for all of these
2. Some options with certain values are making other ones superfluous (e.g. `credentials_provider` = `detect`, `iam` or `env` means that I should ignore all other options)

Would there be interest in such feature? If not, how would you suggest solving the problem with dependent config options above?

Related: hashicorp/terraform#1049

Contributor guide

Open the contributing guide

Research direction

Start with helper/schema/schema.go, especially schemaMap.Input and the referenced lines that sort and prompt for options. Read the discussion and related hashicorp/terraform#1049 before attempting implementation. The issue proposes dependent configuration but does not define an accepted design or concrete done criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.