Skip to content

New Code Action: Generate missing required_providers entry #480

Open
@radeksimko

Description

@radeksimko

Current Version

0.16.0

Background

Many users still doesn't seem to use the explicit provider specification via required_providers block, e.g.

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws" # HERE
      version = "~> 3.0"
    }
  }
}

This means LS needs to handle certain edge cases related to "legacy" provider addresses:

Use-cases

Users would benefit from:

  1. knowing that a best practice exists
  2. their config doesn't follow best practice
  3. having an easy way of making the config follow best practice

Attempted Solutions

Point users to documentation, such as https://www.terraform.io/docs/language/providers/requirements.html

Proposal

Help users follow best practice by detecting lack of provider requirements in configuration and offering them to generate the requirements via code action or code lense (not sure what's more appropriate) if they use Terraform 0.13+.

We could also publish diagnostics about this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions