gpt4 book ai didi

azure - Terraform 如何轮换 Azure AD 应用程序 secret

转载 作者:行者123 更新时间:2023-12-02 05:57:29 28 4
gpt4 key购买 nike

我正在尝试使用 Terraform 进行 azure 服务原理密码轮换,他们在最新版本的 azuread 中提供了此轮换功能,

resource "time_rotating" "test" {
rotation_years = 5
lifecycle {
create_before_destroy = true
}
}

resource "azuread_service_principal_password" "service_principal_password" {
service_principal_id = var.sp_internal_id
rotate_when_changed = {
rotation = time_rotating.test.id
}
lifecycle {
create_before_destroy = true
}
}

我只是想当我添加属性rotate_when_changed时,它会根据我正确设置的时间戳创建一个新的密码资源?我想知道这是 Terraform 仅提供的功能还是 Azure AD 的功能?由于 Azure AD 不提供 key 轮换功能,我想知道 Terraform 是如何实现这种轮换的?

最佳答案

I just want to when I add the attribute rotate_when_changed it willcreate a new password resource according to the timestamp I set right? and I want to know that this is a feature that Terraform onlyprovides or this is a feature from Azure AD ? since Azure AD does notprovide the key rotation feature, I'm wondering how Terraform isachieving this rotation ?

您是对的,它仅是 terraform 功能不是 AzureAD 功能。当我们从 terraform 创建密码时,它不再使用值,如果您没有提供任何 end_date_relative ,那么它会将有效期设置为默认值 2 年。但出于安全原因,如果我们想根据时间轮换更改密码的值,那么我们只需设置 rotate_when_changed 并修改它即可。

这在 GitHub Issue 中得到了建议和增强。 .

示例:

我使用以下代码在一小时后轮换值:

resource "time_rotating" "test" {
rotation_hours = 1
lifecycle {
create_before_destroy = true
}
}

resource "azuread_application_password" "example" {
application_object_id = azuread_application.example.object_id
rotate_when_changed = {
rotation = time_rotating.test.id
}
lifecycle {
create_before_destroy = true
}
}

初始输出:

enter image description here

如果我执行 terraform 计划,1 小时后,它会显示密码将被替换,如下所示,但在 1 小时之前,它只会显示未检测到任何更改:

enter image description here

注意:这很有用,因为您不必再​​次销毁密码 block 并重新创建它。仅当您的时间轮换完​​成时,如果您执行应用,那么 terraform 将仅替换密码 block 并根据您的要求再次设置时间轮换。

关于azure - Terraform 如何轮换 Azure AD 应用程序 secret ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70108188/

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