Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for setting profile like in the aws provider #113

Open
hoxu opened this issue Feb 24, 2023 · 0 comments · May be fixed by #126
Open

Add support for setting profile like in the aws provider #113

hoxu opened this issue Feb 24, 2023 · 0 comments · May be fixed by #126

Comments

@hoxu
Copy link
Contributor

hoxu commented Feb 24, 2023

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())

pwhittlesea added a commit to pwhittlesea/terraform-provider-redshift that referenced this issue Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant