File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"log"
6
6
7
+ "github.com/hashicorp/hcl/v2"
7
8
tfaddr "github.com/hashicorp/terraform-registry-address"
8
9
"github.com/terraform-linters/tflint-plugin-sdk/hclext"
9
10
sdk "github.com/terraform-linters/tflint-plugin-sdk/tflint"
@@ -126,7 +127,14 @@ func (r *TerraformRequiredProvidersRule) Check(runner *tflint.Runner) error {
126
127
continue
127
128
}
128
129
129
- val , diags := provider .Expr .Value (nil )
130
+ val , diags := provider .Expr .Value (& hcl.EvalContext {
131
+ Variables : map [string ]cty.Value {
132
+ // configuration_aliases can declare additional provider instances
133
+ // required provider "foo" could have: configuration_aliases = [foo.a, foo.b]
134
+ // @see https://www.terraform.io/language/modules/develop/providers#provider-aliases-within-modules
135
+ name : cty .DynamicVal ,
136
+ },
137
+ })
130
138
if diags .HasErrors () {
131
139
return diags
132
140
}
Original file line number Diff line number Diff line change @@ -205,6 +205,26 @@ provider "template" {
205
205
},
206
206
},
207
207
},
208
+ {
209
+ Name : "version set with configuration_aliases" ,
210
+ Content : `
211
+ terraform {
212
+ required_providers {
213
+ template = {
214
+ source = "hashicorp/template"
215
+ version = "~> 2"
216
+
217
+ configuration_aliases = [template.alias]
218
+ }
219
+ }
220
+ }
221
+
222
+ data "template_file" "foo" {
223
+ provider = template.alias
224
+ }
225
+ ` ,
226
+ Expected : tflint.Issues {},
227
+ },
208
228
{
209
229
Name : "version set with alias" ,
210
230
Content : `
You can’t perform that action at this time.
0 commit comments