Skip to content

Commit

Permalink
fix: Make region is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
uanid committed Jan 9, 2024
1 parent c011a7c commit 04a69c9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Provider() *schema.Provider {
},
"region": {
Type: schema.TypeString,
Required: true,
Optional: true,
},
"profile": {
Type: schema.TypeString,
Expand Down Expand Up @@ -162,7 +162,7 @@ type ProviderConfig struct {
AccessKey *string
SecretAccessKey *string
SessionToken *string
Region string
Region *string
Profile *string
}
OidcAuth *struct {
Expand Down Expand Up @@ -197,11 +197,10 @@ func loadProviderConfiguration(d *schema.ResourceData) ProviderConfig {
AccessKey *string
SecretAccessKey *string
SessionToken *string
Region string
Region *string
Profile *string
}{
ClusterName: attr["cluster_name"].(string),
Region: attr["region"].(string),
}
if attr["access_key"] != nil {
config.AwsAuth.AccessKey = fwtype.String(attr["access_key"].(string))
Expand All @@ -212,6 +211,9 @@ func loadProviderConfiguration(d *schema.ResourceData) ProviderConfig {
if attr["session_token"] != nil {
config.AwsAuth.SessionToken = fwtype.String(attr["session_token"].(string))
}
if attr["region"] != nil {
config.AwsAuth.Region = fwtype.String(attr["region"].(string))
}
if attr["profile"] != nil {
config.AwsAuth.Profile = fwtype.String(attr["profile"].(string))
}
Expand Down Expand Up @@ -248,7 +250,7 @@ func initializeBluechipToken(ctx context.Context, authClient *bluechip_authentic
})
}
if config.AwsAuth != nil {
token, err := authClient.LoginWithAws(ctx, config.AwsAuth.ClusterName, defaultString(config.AwsAuth.AccessKey, ""), defaultString(config.AwsAuth.SecretAccessKey, ""), defaultString(config.AwsAuth.SessionToken, ""), config.AwsAuth.Region, defaultString(config.AwsAuth.Profile, ""))
token, err := authClient.LoginWithAws(ctx, config.AwsAuth.ClusterName, defaultString(config.AwsAuth.AccessKey, ""), defaultString(config.AwsAuth.SecretAccessKey, ""), defaultString(config.AwsAuth.SessionToken, ""), defaultString(config.AwsAuth.Region, ""), defaultString(config.AwsAuth.Profile, ""))
if err == nil {
return token, nil
}
Expand Down

0 comments on commit 04a69c9

Please sign in to comment.