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

Fix error changing ownership when deleting a user, if the current user has temporary credentials#4

Merged
winglot merged 1 commit intobrainly:masterfrom
sworisbreathing:fix-delete-user-when-using-temporary-credentials
Jul 15, 2021
Merged

Fix error changing ownership when deleting a user, if the current user has temporary credentials#4
winglot merged 1 commit intobrainly:masterfrom
sworisbreathing:fix-delete-user-when-using-temporary-credentials

Conversation

@sworisbreathing
Copy link
Copy Markdown
Contributor

@sworisbreathing sworisbreathing commented Jul 14, 2021

When deleting a user, the provider attempts to chown all of the user's objects to $REDSHIFT_USER. If you use temporary credentials provided by GetClusterCredentials the username you need to authenticate as is prefixed with either IAM: or IAMA:. However, the username needed for the chown is the non-prefixed one.

This PR fixes the issue by stripping these specific prefixes from the chown statements (and also parameterizes them).

You can reproduce the error like so:

username=<your db username>
clusterIdentifier=<redshift cluster identifier>
credentials="$(aws redshift get-cluster-credentials --db-user=$username --cluster-identifier=$clusterIdentifier)"

# This assumes you have jq on your PATH. otherwise just "echo $credentials" and set the values explicitly
export REDSHIFT_USER="$(echo $credentials | jq -r .DbUser)"
export REDSHIFT_PASSWORD="$(echo $credentials | jq -r .DbPassword)"

make testacc

Note: while this PR is in a similar vein to #3 the underlying issue isn't necessarily dependent upon the changes there.

@winglot winglot merged commit 4f02a78 into brainly:master Jul 15, 2021
@winglot winglot added the bug Something isn't working label Jul 15, 2021
@sworisbreathing sworisbreathing deleted the fix-delete-user-when-using-temporary-credentials branch July 16, 2021 00:00
StevenKGER referenced this pull request in dbsystel/terraform-provider-redshift Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants