After executing the aws command line, I want to get the Profile List Now Defined. I think I can do it if I write a little grep, but for example, every time I ssh the server, I don't bring the script and it's a bit troublesome to type grep. If aws-cli has this feature, it seems relatively easy to do, for example, by doing all kinds of operations in aws-shell.
aws configure
?
It is slightly different from getting the list, but it refers to what is defined in the input complement of the aws command installed with pip.
After the --profile
option, you can save it in Tab to see the profile name defined as follows:
$awsec2describe-instances --profile
default prof1 prof2
$
Credentials currently configured in some way, such as aws configure
or AWS_DEFAULT_PROFILE
, can be found in the following commands:
$awssts get-caller-identity
{
"Account": "*****",
"UserId": "*****",
"Arn": "arn:aws:iam::****"
}
You can check the contents of the configuration file by using the following command:
Among them is a list of currently configured profiles.
cat to /.aws/credentials
AWS has the configuration and credentials files.Some profiles are written only in the configuration file through /.aws/config
, while others are written only in the credentials file through /.aws/credentials
.
You can also use the environment variable. You can also use AWS_CONFIG_FILE
or AWS_SHARED_CREMENTALS_FILE
to switch to another configuration or credentials file.
Therefore, looking only at through /.aws/credentials
may not solve the problem.
As suggested by ksaito
$aws --profile
default prof1 prof2
The output is a complementary candidate, so you can get a list of questions by directly executing the complementary command.Specifically
$env COMP_LINE='aws --profile'aws_completer
default
prof1
prof2
I wonder if it looks like this.(env
doesn't matter.)
© 2024 OneMinuteCode. All rights reserved.