获取 AWS 访问密钥 ID?

huangapple go评论87阅读模式
英文:

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"
        }
    ]
}

huangapple
  • 本文由 发表于 2023年7月28日 02:50:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76782651.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定