From e1375375969378fa612908362ee3e9aa11da89d9 Mon Sep 17 00:00:00 2001 From: Elie Date: Mon, 15 Feb 2021 14:21:29 +0100 Subject: [PATCH] Add a name to terraform provider --- pkg/remote/aws/provider.go | 4 +++- pkg/remote/terraform/provider.go | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/remote/aws/provider.go b/pkg/remote/aws/provider.go index 1d6cd314..7a9dbde5 100644 --- a/pkg/remote/aws/provider.go +++ b/pkg/remote/aws/provider.go @@ -42,8 +42,9 @@ type AWSTerraformProvider struct { func NewAWSTerraformProvider() (*AWSTerraformProvider, error) { p := &AWSTerraformProvider{} + providerKey := "aws" installer, err := tf.NewProviderInstaller(tf.ProviderConfig{ - Key: "aws", + Key: providerKey, Version: "3.19.0", Postfix: "x5", }) @@ -54,6 +55,7 @@ func NewAWSTerraformProvider() (*AWSTerraformProvider, error) { SharedConfigState: session.SharedConfigEnable, })) tfProvider, err := terraform.NewTerraformProvider(installer, terraform.TerraformProviderConfig{ + Name: providerKey, DefaultAlias: *p.session.Config.Region, GetProviderConfig: func(alias string) interface{} { return awsConfig{ diff --git a/pkg/remote/terraform/provider.go b/pkg/remote/terraform/provider.go index 04c87e33..dcab4631 100644 --- a/pkg/remote/terraform/provider.go +++ b/pkg/remote/terraform/provider.go @@ -27,6 +27,7 @@ import ( // we'll have an alias per region, and the alias IS the region itself. // So we can query resources using a specific custom provider configuration type TerraformProviderConfig struct { + Name string DefaultAlias string GetProviderConfig func(alias string) interface{} } @@ -71,7 +72,6 @@ func (p *TerraformProvider) Init() error { if err != nil { return err } - fmt.Printf("Provider initialized (alias=%s)\n", p.Config.DefaultAlias) return nil } @@ -125,6 +125,12 @@ func (p *TerraformProvider) configure(alias string) error { "alias": alias, }).Debug("New gRPC client started") + fmt.Printf("Terraform provider initialized (name=%s", p.Config.Name) + if alias != "" { + fmt.Printf(", alias=%s", alias) + } + fmt.Print(")\n") + return nil }