- Más nuevo
- Más votos
- Más comentarios
The AWS CLI stores the access keys and other configuration settings in a configuration file. By default, this file is located at "~/.aws/credentials" on Linux, macOS, or Unix-based systems, and "C:\Users<username>.aws\credentials" on Windows.
To resolve the issue and ensure you are using the access keys of the newly created IAM user, you can do the following:
Open the AWS CLI configuration file in a text editor. Locate the file "~/.aws/credentials" (or the appropriate file path based on your operating system). Look for the section in the file corresponding to the old IAM user that you deleted. It will have a format like:
[profile_name] aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_SECRET_KEY
Delete the section for the old IAM user from the configuration file. Save the changes to the configuration file and close the editor.
Now, when you run the "aws configure" command, it should prompt you to enter the access keys for the new IAM user. Provide the new access keys, and the AWS CLI will use them for subsequent operations.
If you have multiple profiles configured in your AWS CLI, you can also specify the profile explicitly using the "--profile" flag when running AWS CLI commands. For example:
aws s3 ls --profile new_profile
Follow below simple steps to reconfigure your AWS credentials.
step1: Delete existing AWS credentials
$ sudo nano ~/.aws/credentials
step2: Reconfiute AWS credentials.
aws configure
It should prompt you to enter new access keys for the IAM user.
how can i choose from cli which iam user to select if i have more than one iam user?
If you have multiple IAM users and frequently switch between them, you can create separate AWS CLI profiles for each IAM user. This approach allows you to easily switch between different IAM users each time. You can define profiles in the AWS CLI configuration file.
To create a profile for each IAM user:
Open or create the AWS CLI configuration file located at ~/.aws/config (Unix/Linux) or %USERPROFILE%.aws\config (Windows). Add a new profile for each IAM user using the following syntax:
[profile profile_name] region = us-west-2 aws_access_key_id = <ACCESS_KEY> aws_secret_access_key = <SECRET_KEY>
Replace profile_name, <ACCESS_KEY>, and <SECRET_KEY> with the appropriate values for each IAM user. Save the configuration file.
Now, you can specify the desired profile when executing AWS CLI commands using the --profile option. For example:
aws s3 ls --profile profile_name
Replace profile_name with the name of the **desired profile ** you defined in the AWS CLI configuration file.
Contenido relevante
- OFICIAL DE AWSActualizada hace 3 años
- OFICIAL DE AWSActualizada hace 2 años
Wow Mate thanks!! I'm new and I study about AWS solution architect in these days. You help me to solve a great problem. I have another question: how can i choose from cli which iam user to select if i have more than one iam user?