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 error changing ownership when deleting a user, if the current user has temporary credentials #4

Conversation

sworisbreathing
Copy link
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants