github.com/jpreese/tflint@v0.19.2-0.20200908152133-b01686250fb6/docs/rules/terraform_required_providers.md (about) 1 # terraform_required_providers 2 3 Require that all providers have version constraints through `required_providers`. 4 5 ## Configuration 6 7 ```hcl 8 rule "terraform_required_providers" { 9 enabled = true 10 } 11 ``` 12 13 ## Examples 14 15 ```hcl 16 provider "template" {} 17 ``` 18 19 ``` 20 $ tflint 21 1 issue(s) found: 22 23 Warning: Missing version constraint for provider "template" in "required_providers" (terraform_required_providers) 24 25 on main.tf line 1: 26 1: provider "template" {} 27 28 Reference: https://github.com/terraform-linters/tflint/blob/v0.18.0/docs/rules/terraform_required_providers.md 29 ``` 30 31 <hr> 32 33 ```hcl 34 provider "template" { 35 version = "2" 36 } 37 ``` 38 39 ``` 40 $ tflint 41 2 issue(s) found: 42 43 Warning: provider.template: version constraint should be specified via "required_providers" (terraform_required_providers) 44 45 on main.tf line 1: 46 1: provider "template" { 47 48 Reference: https://github.com/terraform-linters/tflint/blob/v0.18.0/docs/rules/terraform_required_providers.md 49 50 Warning: Missing version constraint for provider "template" in "required_providers" (terraform_required_providers) 51 52 on main.tf line 1: 53 1: provider "template" { 54 55 Reference: https://github.com/terraform-linters/tflint/blob/v0.18.0/docs/rules/terraform_required_providers.md 56 ``` 57 58 ## Why 59 60 Providers are plugins released on a separate rhythm from Terraform itself, and so they have their own version numbers. For production use, you should constrain the acceptable provider versions via configuration, to ensure that new versions with breaking changes will not be automatically installed by `terraform init` in future. 61 62 ## How To Fix 63 64 Add the [`required_providers`](https://www.terraform.io/docs/configuration/terraform.html#specifying-required-provider-versions) block to the `terraform` configuration block and include current versions for all providers. For example: 65 66 ```tf 67 terraform { 68 required_providers { 69 template = "~> 2.0" 70 } 71 } 72 ``` 73 74 Provider version constraints can be specified using a [version argument within a provider block](https://www.terraform.io/docs/configuration/providers.html#provider-versions) for backwards compatability. This approach is now discouraged, particularly for child modules.