Add a name to terraform provider

main
Elie 2021-02-15 14:21:29 +01:00
parent 32fa012357
commit e137537596
No known key found for this signature in database
GPG Key ID: 399AF69092C727B6
2 changed files with 10 additions and 2 deletions

View File

@ -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{

View File

@ -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
}