Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

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

@hoxu

Description

@hoxu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions