英文:
Get AWS Access Key ID?
问题
当IAM用户使用AWS CLI进行AWS API请求时,是否有调用来获取AWS访问密钥ID?
我知道可以使用aws sts get-caller-identity
获取用户名,但不确定如何确定有效的AWS访问密钥ID?搜索了AWS IAM文档,但没有找到相关的调用。
我已经有了密钥,但凭据可能来自凭据提供程序的任何地方(环境变量、配置文件、EC2元数据),因此我需要能够确定活动密钥标识符。
英文:
When IAM user is making an AWS API request using aws cli, is there a call to get aws access key id?
I know I can get the username with aws sts get-caller-identity
, but not sure how to determine effective aws access key id? Searched aws iam docs, but haven't found a relevant call.
I already have the keys, but credentials might be coming from anywhere in the Credentials Provider (environment variables, config file, EC2 metadata) so I need to be able to determine active key identifier.
答案1
得分: 1
我们可以使用以下命令查找访问密钥 ID。这将返回与指定 IAM 用户关联的所有访问密钥 ID。
aws iam list-access-keys --user [用户名]
我们将获得类似于以下的输出:
{
"AccessKeyMetadata": [
{
"UserName": "...",
"AccessKeyId": "...",
"Status": "Active",
"CreateDate": "2023-05-14T09:51:39+00:00"
}
]
}
英文:
We can find access key IDs using the following command. This will give all the access key IDs associated with the specified IAM user
aws iam list-access-keys --user [Username]
We will get an output similar to this:
{
"AccessKeyMetadata": [
{
"UserName": "...",
"AccessKeyId": "...",
"Status": "Active",
"CreateDate": "2023-05-14T09:51:39+00:00"
}
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论