gpt4 book ai didi

amazon-web-services - 如何检查 AWS secretsmanager 轮换是否成功完成

转载 作者:行者123 更新时间:2023-12-05 02:52:42 25 4
gpt4 key购买 nike

在 AWS secretsmanager 中创建一个 secret ,使用 lambda 函数启用自动轮换。当我第一次从 cli 触发旋转时,它还没有完成。这是在 aws 控制台手动更新 secret 时的初始 secret 状态。

# aws secretsmanager list-secret-version-ids --secret-id ******
{
"Versions": [
{
"VersionId": "9e82b9e2-d074-478e-83a5-baf4e578cb49",
"VersionStages": [
"AWSCURRENT"
],
"LastAccessedDate": 1592870400.0,
"CreatedDate": 1592889913.431
},
{
"VersionId": "e32ddaf8-7f21-40e2-adf8-f976b8f3f104",
"VersionStages": [
"AWSPREVIOUS"
],
"LastAccessedDate": 1592870400.0,
"CreatedDate": 1592887518.46
}
],
"ARN": "arn:aws:secretsmanager:us-east-1:***********:secret:***********",
"Name": "*******"
}

现在我从 aws cli 触发了旋转

aws secretsmanager rotate-secret --secret-id ******

# aws secretsmanager list-secret-version-ids --secret-id ********
{
"Versions": [
{
"VersionId": "704102f3-b36d-4529-b257-0457354d3c93",
"VersionStages": [
"AWSPENDING"
],
"CreatedDate": 1592890351.334
},
{
"VersionId": "e32ddaf8-7f21-40e2-adf8-f976b8f3f104",
"VersionStages": [
"AWSPREVIOUS"
],
"LastAccessedDate": 1592870400.0,
"CreatedDate": 1592887518.46
},
{
"VersionId": "9e82b9e2-d074-478e-83a5-baf4e578cb49",
"VersionStages": [
"AWSCURRENT"
],
"LastAccessedDate": 1592870400.0,
"CreatedDate": 1592889913.431
}
],
"ARN": "arn:aws:secretsmanager:us-east-1:**********:secret:********",
"Name": "********"
}

Cloudwatch 日志在此 createSecret 处停止:成功为 ARN arn:aws:secretsmanager:xxxxxxx 设置 secret 。。看起来只调用了 createsecret 函数。当我再次旋转 secret 时,在 cli 中获取此输出

An error occurred (InvalidRequestException) when calling the RotateSecret operation: A previous rotation isn't complete. That rotation will be reattempted.

无法理解发生了什么。有人可以帮忙吗?

最佳答案

不幸的是,没有开箱即用的方法,因为 Secrets Manger 没有内置 SNS 通知,也没有用于轮换完成的 CloudWatch Events。

因此,您必须自己构建解决方案,这可以使用 SDK 或 CLI 来完成。

对于 CLI,您可以使用 describe-secret并循环提取 secret 细节。在循环中,您必须查看版本的 AWSPENDINGAWSCURRENT 标签。

来自docs :

If instead the AWSPENDING staging label is present but is not attached to the same version as AWSCURRENT then any later invocation of RotateSecret assumes that a previous rotation request is still in progress and returns an error.

所以基本上,看看你的输出:

        {
"VersionId": "704102f3-b36d-4529-b257-0457354d3c93",
"VersionStages": [
"AWSPENDING"
],
"CreatedDate": 1592890351.334
}

您有一个带有 AWSPENDING 标签的版本,它与 AWSCURRENT未附加到同一版本。这表明旋转正在进行

当版本处于以下两种状态之一时,轮换完成:

The AWSPENDING and AWSCURRENT staging labels are attached to the same version of the secret, or The AWSPENDING staging label is not attached to any version of the secret.

关于amazon-web-services - 如何检查 AWS secretsmanager 轮换是否成功完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62528127/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com