微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pulumi:将Web应用程序添加到密钥库访问策略,读取机密并将其设置为应用程序设置

如何解决pulumi:将Web应用程序添加到密钥库访问策略,读取机密并将其设置为应用程序设置

我正在使用azure nextgen提供程序。给定具有存储秘密vault的密钥仓库secret1

  • 如何将Web应用程序添加到密钥库的访问策略中?
  • 我如何阅读机密信息(获取包含版本的URL)并将其设置为网络应用的设置?
  • 首先需要做什么?

在这些情况下,我没有在pulumi文档中找到任何功能

脚本,包括缺少的部分:

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

解决方法

正确的顺序是:

  1. 秘密
  2. 带有秘密的Web应用
  3. 访问政策

KeyVault具有一个奇怪的API模型,该模型仅通过Azure资源管理器部分公开。目前,Azure NextGen不支持机密,密钥,证书或访问策略。在this issue中进行了跟踪。

同时,您可以使用“旧的” Azure提供程序来添加缺少的对象。可以在同一程序中使用这两个提供程序。 This example接近您要实现的有序竞争。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。