The Terraform aws provider allows setting AWS profile like this:
provider "aws" {
profile = "customprofile"
}
Currently this Redshift provider does not allow that. The underlying aws-sdk-go-v2 implicitly uses the environment variable AWS_PROFILE if set.
This means that if you are using AWS profiles, you need to remember to run Terraform with AWS_PROFILE=customprofile terraform plan, or the GetClusterCredentials call will fail. This is pretty cumbersome.
I think it would be a good idea to add a top level configuration option to this Redshift provider, like this:
provider "redshift" {
profile = "customprofile"
}
Implementing it should be pretty straight-forward unless I'm mistaken.
The aws-sdk-go-v2 allows specifying a profile explicitly:
cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithSharedConfigProfile("test-account"))
The provider schema would need to be expanded with the profile option:
|
func Provider() *schema.Provider { |
|
return &schema.Provider{ |
|
Schema: map[string]*schema.Schema{ |
The redshiftSdkClient function would need to pass the profile name to LoadDefaultConfig, if set, or else fall back to calling it as before:
|
func redshiftSdkClient(d *schema.ResourceData) (*redshift.Client, error) { |
|
cfg, err := config.LoadDefaultConfig(context.TODO()) |
The Terraform aws provider allows setting AWS profile like this:
Currently this Redshift provider does not allow that. The underlying aws-sdk-go-v2 implicitly uses the environment variable
AWS_PROFILEif set.This means that if you are using AWS profiles, you need to remember to run Terraform with
AWS_PROFILE=customprofile terraform plan, or theGetClusterCredentialscall will fail. This is pretty cumbersome.I think it would be a good idea to add a top level configuration option to this Redshift provider, like this:
Implementing it should be pretty straight-forward unless I'm mistaken.
The aws-sdk-go-v2 allows specifying a profile explicitly:
The provider schema would need to be expanded with the
profileoption:terraform-provider-redshift/redshift/provider.go
Lines 24 to 26 in bbfe59a
The
redshiftSdkClientfunction would need to pass the profile name toLoadDefaultConfig, if set, or else fall back to calling it as before:terraform-provider-redshift/redshift/provider.go
Lines 234 to 235 in bbfe59a