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

Fix #113 Allow setting of a AWS profile when creating the SDK config #126

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Optional:
- **db_groups** (Set of String) A list of the names of existing database groups that the user will join for the current session, in addition to any group memberships for an existing user. If not specified, a new user is added only to PUBLIC.
- **duration_seconds** (Number) The number of seconds until the returned temporary password expires.
- **region** (String) The AWS region where the Redshift cluster is located.
- **profile** (String) The AWS profile to use when requesting temporary credentials.

<a id="nestedblock--temporary_credentials--assume_role"></a>
### Nested Schema for `temporary_credentials.assume_role`
Expand Down
13 changes: 12 additions & 1 deletion redshift/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func Provider() *schema.Provider {
Optional: true,
Description: "The AWS region where the Redshift cluster is located.",
},
"profile": {
Type: schema.TypeString,
Optional: true,
Description: "The AWS profile to use when requesting temporary credentials.",
},
"auto_create_user": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -232,7 +237,13 @@ func temporaryCredentials(username string, d *schema.ResourceData) (string, stri
}

func redshiftSdkClient(d *schema.ResourceData) (*redshift.Client, error) {
cfg, err := config.LoadDefaultConfig(context.TODO())
loadOptions := []func(*config.LoadOptions) error{}

if profile := d.Get("temporary_credentials.0.profile").(string); profile != "" {
loadOptions = append(loadOptions, config.WithSharedConfigProfile(profile))
}

cfg, err := config.LoadDefaultConfig(context.TODO(), loadOptions...)
if err != nil {
return nil, err
}
Expand Down