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

AWS Toolkit erased the content of the credentials file #454

Open
TheBlueSky opened this issue Jul 25, 2024 · 5 comments
Open

AWS Toolkit erased the content of the credentials file #454

TheBlueSky opened this issue Jul 25, 2024 · 5 comments
Labels
bug We can reproduce the issue and confirmed it is a bug.

Comments

@TheBlueSky
Copy link

Describe the bug
Recently, AWS Toolkit was updated to version 1.55.2.0. I got the yellow banner in Visual Studio that suggest I configure the extension using "Extensions > AWS Toolkit > Getting Started" menu option. I did that, selected "AWS Explorer", and then clicked "Edit credentials file directly...", because I already have the required profiles configured.

AWS Toolkit, replaced the content of the credentials file with the following text:

# AWS credentials file used by AWS CLI, SDKs, and tools.
# Created by AWS Toolkit for Visual Studio. https://aws.amazon.com/visualstudio/
#
# Each [section] in this file declares a named "profile", which can be selected
# in tools like AWS Toolkit to choose which credentials you want to use.
#
# See also:
#   https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html
#   https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html

This all happens without any warning and before even configuring and saving anything.

To Reproduce

Expected behavior
AWS Toolkit leave the credentials file unchanged, unless the user configures something. In such case, AWS Toolkit must append to the file, not replace it.

Screenshots
N/A

Toolkit Logs
N/A

Development System (please complete the following information):

  • Windows Version: Windows 10 22H2
  • Visual Studio Version: 17.10.4
  • AWS Toolkit for Visual Studio Version: 1.55.2.0

Additional context
I have no addition context to add, but I would like to express my frustration. Any "destructive" action must not happen without the user's knowledge. It does not make sense to assume that the file does not exist or its content do not matter.

@TheBlueSky TheBlueSky added the bug We can reproduce the issue and confirmed it is a bug. label Jul 25, 2024
@shruti0085
Copy link
Contributor

shruti0085 commented Jul 25, 2024

Hi @TheBlueSky,

Can you provide details about a few things for us to investigate this further?

  • Were your previous profiles saved in credentials file in this default location : %USERPROFILE%\.aws\config %USERPROFILE%\.aws\credential? If not, did you specify an alternate path using the guidelines here ?
  • Before upgrading to v1.55.2.0 did you use a different version of the toolkit to visualize your AWS resources in the AWS Explorer?
  • Before following the instructions from Getting Started, did the AWS Explorer show up in the IDE with a list of credential profiles you had already configured to choose from?

@TheBlueSky
Copy link
Author

Hi @shruti0085,

The answers to your questions are:

  • Yes, my previous credentials file was in the default location and I did not specify an alternative path.
  • If you mean seeing the resources in AWS Explorer, then yes, I did. AWS Explorer used my then-existing credentials file to show the resources that are specific to the selected profile.
  • If you mean the Credentials dropdown list of AWS Explorer, then yes. See the answer to the previous question. I used the dropdown menu to switch profiles and see the resources that are specific to the selected profile.

@shruti0085
Copy link
Contributor

@TheBlueSky thanks for confirming the above.
We have released v1.56.0.0 of the toolkit which contains some improvements and logging related to the Edit Credentials option. Can you please install that version and try again? To avoid any risk of losing your credentials file, please keep a copy of it in a separate location before you try again.
If you continue to see the issue, please attach your logs as they may offer us some additional insights.

@shruti0085 shruti0085 added the needs-response Waiting on additional info and feedback. Will move to `closing-soon` in 30 days label Aug 5, 2024
Copy link

github-actions bot commented Sep 1, 2024

This issue is missing required information and will be closed in 7 days. To keep the issue open, leave a comment.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 7 days unless further comments are made. label Sep 1, 2024
@TheBlueSky
Copy link
Author

I am on v1.57.0.0, and it does not erase the credentials file any more.

However, it still adds the following text to the file, directly after the last character in the file, whether this text already in the file of not:

# AWS credentials file used by AWS CLI, SDKs, and tools.
# Created by AWS Toolkit for Visual Studio. https://aws.amazon.com/visualstudio/
#
# Each [section] in this file declares a named "profile", which can be selected
# in tools like AWS Toolkit to choose which credentials you want to use.
#
# See also:
#   https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html
#   https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html

This can make the credentials in the file invalid. For example, if the last line in my file is (without line break):

aws_session_token=someaccesstoken

It becomes:

aws_session_token=someaccesstoken# AWS credentials file used by AWS CLI, SDKs, and tools.

It will be helpful, instead of appending the text to the file "blindly", to:

  • Check if the text already exists.
  • If it is necessary to add the text, add it to the top, instead.
  • If there is a reason to append it to the end, make sure that there is a line break between the last line in the file and this text.
  • Find a better home for this text, instead of polluting the credentials file.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 7 days unless further comments are made. needs-response Waiting on additional info and feedback. Will move to `closing-soon` in 30 days labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug We can reproduce the issue and confirmed it is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants