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

Support backend config files (for init -backend-config=PATH) #518

Open
radeksimko opened this issue May 19, 2021 · 0 comments
Open

Support backend config files (for init -backend-config=PATH) #518

radeksimko opened this issue May 19, 2021 · 0 comments

Comments

@radeksimko
Copy link
Member

radeksimko commented May 19, 2021

Depends on #285


Current Version

0.16.2

Use-cases

Some users declare the configuration for their state backend via config files, as documented at https://www.terraform.io/docs/language/settings/backends/configuration.html#partial-configuration

Typically such files would be committed within the repository, but there was no established convention for names of such files until recently. Some people seem call them backend.hcl.

A new convention was therefore established: *.<backend-name>.tfbackend to be communicated as terraform-backend-NAME language ID.

Users would benefit from having the same level of support they get for Terraform configurations (*.tf) for these files too.

Completion

In an empty *.s3.tfbackend file, completion would bring up e.g. following fields:

  • bucket Required, string - Name of the S3 Bucket
  • key Required, string - Path to the state file inside the S3 Bucket
  • region Required, string - AWS Region of the S3 Bucket and DynamoDB Table (if used)
  • etc.

Hover

If user hovers over bucket in the following config

bucket = "mybucket"

they would be presented with a popup with details about the field, e.g.

_Required, string_
Name of the S3 Bucket.

Semantic Tokens

All valid attributes would be reported as attribute tokens and compatible expressions would be highlighted as such.

bucket = "terraform-state-prod"

i.e. bucket would be reported as attribute and "terraform-state-prod" would be reported as string.

Diagnostics

Duplicate attributes, or invalid config (e.g. unknown attribute or wrong type for known attribute) would be reported upon save of the file. For example

buket = "test"

would yield the following (or similar) diagnostic

Unsupported argument: An argument named "buket" is not expected here.

Proposal

  • Establish a naming convention, such that we know what backend type is the configuration for, e.g. *.s3.tfbackend
  • Leverage backend schema done as part of Add schema for backends #285
  • Implement new module operation for parsing *.tfbackend files
  • Recognize new LanguageID in all relevant RPC methods, e.g.
    • textDocument/didOpen
    • textDocument/didSave
    • textDocument/didChange
    • textDocument/completion
    • textDocument/hover
    • textDocument/semanticTokens
    • textDocument/documentLink (basically to be ignored as there's most likely no linkable content)
  • Implement formatting for this type of file in textDocument/formatting
  • Report duplicates, mismatching types or any similar diagnostics via textDocument/publishDiagnostics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant