AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-18027197

Container-Man's questions

Martin Hope
Container-Man
Asked: 2023-10-20 00:32:43 +0800 CST

Terraform 无法连接 NULL 值

  • 5

我的目标是使用 Terraform 实现以下 URL。

ec2-environment1-region1.special.myurl.com
ec2-environment2-region1.special.myurl.com
ec2-environment3-region1.special.myurl.com
ec2-environment4-region2.myurl.com
ec2-environment5-region3.myurl.com

我使用了连接功能。下面是代码。

join(".", ["ec2-${var.env}-${var.region}", var.region == "region1" ? "special" : null, "myurl.com"])

因此,当我传递var.region == "region1"URL 时,它会正确创建,如下所示:

ec2-environment1-region1.special.myurl.com

但是,如果我传递其他内容而不是region1它var.region,则会出现以下错误。

Invalid value for "lists" parameter: element 1 is null; cannot concatenate null values.
if-statement
  • 1 个回答
  • 16 Views
Martin Hope
Container-Man
Asked: 2023-08-28 19:37:07 +0800 CST

Terraform Azure 后端问题

  • 5

我们使用 Azure 作为 Terraform 代码的后端。下面是代码。

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.40.0"
    }
  }

  backend "azurerm" {
    resource_group_name  = "test"
    storage_account_name = "test"
    container_name       = "test"
    key                  = "test.tfstate"
    tenant_id            =  "abc"
  }
}

provider "azurerm" {
  features {}
  alias               = "new-new"
  subscription_id     = var.another_subscription
}

provider "azurerm" {
  features {}
}

我已使用以下命令以服务主体用户身份登录:

az login --service-principal -t tenant-id-here -u object-id-of-sp -p client-secret-of-sp

当我terraform init这样做时,会出现以下错误:

Initializing the backend...
╷

    │ Error: Error building ARM Config: Authenticating using the Azure CLI is only supported as a User (not a Service Principal).
    │ 
    │ To authenticate to Azure using a Service Principal, you can use the separate 'Authenticate using a Service Principal'
    │ auth method - instructions for which can be found here: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_client_secret
    │ 
    │ Alternatively you can authenticate using the Azure CLI by using a User Account.
  • 1 个回答
  • 56 Views
Martin Hope
Container-Man
Asked: 2023-08-18 21:40:17 +0800 CST

资源之间的 Terraform 链接 for_each

  • 4

变量.tf

variable "custom_ids" {
  type    = set(string)
  default = ["b4d2d", "c928f140e8"]
}

主.tf

resource "azuread_application" "my-test-app" {
  for_each     = var.custom_ids
  display_name = "testing-application"
  owners       = [data.azuread_client_config.current.object_id , each.value ] 
}

resource "azuread_service_principal" "testing-sp" {
  for_each                     = azuread_application.my-test-app
  application_id               = azuread_application.my-test-app.application_id
  app_role_assignment_required = false
  owners                       = [data.azuread_client_config.current.object_id , each.value]
}

错误消息是:

错误:缺少资源实例键 由于 azuread_application.my-test-app 设置了“for_each”,因此必须在特定实例上访问其属性。│ │ 例如,要与引用资源的索引相关联,请使用: │ azuread_application.my-test-app[each.key]

提到这个:https://developer.hashicorp.com/terraform/language/meta-arguments/for_each#chaining-for_each- Between-resources

这里有什么问题?

新错误:

│ 错误:不支持的属性 │ │ my-service-principals.tf 第 24 行,资源“azure_service_principal”“testing-sp”中: │ 24: application_id = every.value.application_id │ ├───────── ──────── │ │ every.value 是一组字符串 │ │ 该值没有任何属性。

  • 1 个回答
  • 28 Views
Martin Hope
Container-Man
Asked: 2023-08-17 20:48:26 +0800 CST

Terraform 单变量问题的多个值

  • 5

我正在尝试使用 Terraform 在 AD 中创建 Azure 应用程序。

resource "azuread_application" "my_ad_app" {
  display_name = "my_app"

  #API Permissions
  required_resource_access {
    resource_app_id = "0000000-000000000000" # Microsoft Graph

    resource_access {
      id   = "df021288-bdef-9214" # User.Read.All
      type = "Role"
    }

    resource_access {
      id   = "18a4783c662c884" # User.Read.All
      type = "Role"
    }

    resource_access {
      id   = "9a5d68c3a30" # Application.Read.All
      type = "Role"
    }

我将创建更多 Azure AD 应用程序并分配相同的 API 权限。将分配许多 API 权限,它们对于我将创建的所有 Azure AD 应用程序都是相同的。由于我将为其创建的所有 Azure AD 应用程序的 API 权限都是相同的,因此我想将整个应用程序分配required_resource_access为变量。

像这样的东西。

#API Permissions
  required_resource_access {
    resource_app_id = "00000003-0000-0000-c000-000000000000" # Microsoft Graph

    resource_access {
     assign the entire part as a variable here? Example: var.ms_graph_api_permission
     }

我尝试将以下内容添加为变量,但似乎不起作用。

variable "ms_graph_api_permission" {
  type = list(string)
  default =

resource_access {
id   = "df021288f22de89214" 
type = "Role"
}

resource_access {
id   = "18a4783e5662c884" 
type = "Role"
}

resource_access {
id   = "9a5d68ac3a30" 
type = "Role"
}
}"

这似乎不起作用。知道如何自动化吗?

我尝试使用当地人。

locals {
  resource_access = [
    {
      id   = "df021288-bdde89214" # User.Read.All
      type = "Role"
    },
    {
      id   = "18a4783c-85e5662c884" # User.Read.All
      type = "Role"
    }
  ]
}

resource "azuread_application" "my_ad_app" {
  display_name = "my_app"

  #API Permissions
  required_resource_access {
    for_each   = {
    for index, az_app_id in local.resource_access:
    az_app_id.id => az_app_id
    }

    resource_app_id = "000000000000" # Microsoft Graph

    resource_access = How should I pass values here using locals??
     
  • 1 个回答
  • 38 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve