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 region support when calling GetClusterCredentials #60

Merged
merged 1 commit into from
Apr 19, 2022
Merged
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 @@ -76,6 +76,7 @@ Optional:
- **auto_create_user** (Boolean) Create a database user with the name specified for the user if one does not exist.
- **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.

<a id="nestedblock--temporary_credentials--assume_role"></a>
### Nested Schema for `temporary_credentials.assume_role`
Expand Down
10 changes: 10 additions & 0 deletions redshift/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func Provider() *schema.Provider {
Description: "The unique identifier of the cluster that contains the database for which you are requesting credentials. This parameter is case sensitive.",
ValidateFunc: validation.StringLenBetween(1, 2147483647),
},
"region": {
Type: schema.TypeString,
Optional: true,
Description: "The AWS region where the Redshift cluster is located.",
},
"auto_create_user": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -231,6 +236,11 @@ func redshiftSdkClient(d *schema.ResourceData) (*redshift.Client, error) {
if err != nil {
return nil, err
}

if region := d.Get("temporary_credentials.0.region").(string); region != "" {
cfg.Region = region
}

if _, ok := d.GetOk("temporary_credentials.0.assume_role"); ok {
var parsedRoleArn string
if roleArn, ok := d.GetOk("temporary_credentials.0.assume_role.0.arn"); ok {
Expand Down