如何解决pulumi:将Web应用程序添加到密钥库访问策略,读取机密并将其设置为应用程序设置
我正在使用azure nextgen提供程序。给定具有存储秘密vault
的密钥仓库secret1
。
脚本,包括缺少的部分:
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";
import * as resources from "@pulumi/azure-nextgen/resources/latest";
import * as web from "@pulumi/azure-nextgen/web/latest";
const config = new pulumi.Config();
const location = config.require("location");
const resourceGroup = new resources.ResourceGroup("rootResourceGroup",{
resourceGroupName: "resources",location,});
const suffix = new random.RandomString("suffix",{
length: 6,special: false,upper: false,});
const appServicePlan = new web.AppServicePlan("appserviceplan",{
name: "my-appservice-plan",resourceGroupName: resourceGroup.name,kind: "Linux",reserved: true,sku: {
name: "B1",tier: "Basic",},});
const vault = ???; // Get the vault by name
const secret1Identifier = vault.???; // fetch the secret by name
const webApp = new web.WebApp("web-app",{
name: pulumi.interpolate`webapp${suffix.result}`,serverFarmId: appServicePlan.id,identity: {
type: "SystemAssigned",siteConfig: {
appSettings: [
{
name: "WEBSITES_ENABLE_APP_SERVICE_STORAGE",value: "false",{
name: "SECRET1",value: pulumi.interpolate`@Microsoft.keyvault(SecretUri=${secret1Identifier})`
}
],alwaysOn: true,});
const principalId = webApp.identity.apply(id => id?.principalId);
vault.??? // Set access policy for web apps principal id
解决方法
正确的顺序是:
- 秘密
- 带有秘密的Web应用
- 访问政策
KeyVault具有一个奇怪的API模型,该模型仅通过Azure资源管理器部分公开。目前,Azure NextGen不支持机密,密钥,证书或访问策略。在this issue中进行了跟踪。
同时,您可以使用“旧的” Azure提供程序来添加缺少的对象。可以在同一程序中使用这两个提供程序。 This example接近您要实现的有序竞争。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。