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-10186343

Elarbe's questions

Martin Hope
Elarbe
Asked: 2025-04-08 19:56:44 +0800 CST

在 filesystem_mirror 位置未找到 Terraform v1.11.3 提供程序

  • 5

我正在尝试安装这个“愚蠢的”api 提供程序,以允许我将 Terraform 与当前在注册表中没有可用提供程序的 api 一起使用:

https://github.com/Mastercard/terraform-provider-restapi

我已经下载了最新版本的 .zipcURL并使用提取了可执行文件chmod +x。

按照 Hashicorp 的文档,我~/.terraformrc 通过显式安装方法创建了一个所需的配置文件,其内容如下:

provider_installation {
  filesystem_mirror {
    path    = "/home/lukerb/.terraform.d/plugins/registry.terraform.io/hashicorp/restapi/1.20.0/linux_amd64/"
    include = ["registry.terraform.io/*/*"]
  }
  direct {
    exclude = ["registry.terraform.io/*/*"]
  }
}

该路径存在,并且正是我之前提取的可执行文件所在的位置,但是当terraform init在与 main.tf 相同的目录中执行时,我收到以下错误

 Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/restiapi: provider registry.terraform.io/hashicorp/restiapi was not found in any of the search
│ locations
│
│   - /home/lukerb/.terraform.d/plugins/registry.terraform.io/hashicorp/restapi/1.20.0/linux_amd64/
╵
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/restapi: provider registry.terraform.io/hashicorp/restapi was not found in any of the search
│ locations
│
│   - /home/lukerb/.terraform.d/plugins/registry.terraform.io/hashicorp/restapi/1.20.0/linux_amd64/

我的 main.tf 包含

terraform {
  required_providers {
    restapi = {
      source = "hashicorp/restapi"
      version = "1.20.0"
    }
  }
}

我激活了详细日志来尝试了解问题所在,据我所知,当尝试初始化时,检查了位置但没有找到任何东西

[TRACE] Selected provider installation method cliconfig.ProviderInstallationFilesystemMirror("/home/lukerb/.terraform.d/plugins/registry.terraform.io/hashicorp/restapi/1.20.0/linux_amd64/") with includes [registry.terraform.io/*/*] and excludes []
[TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes [registry.terraform.io/*/*]
[INFO]  CLI command args: []string{"init"}
Initializing the backend...
[TRACE] Meta.Backend: no config given or present on disk, so returning nil config
[TRACE] Meta.Backend: backend has not previously been initialized in this working directory
[TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
[TRACE] Meta.Backend: instantiated backend of type <nil>
[DEBUG] checking for provisioner in "."
[DEBUG] checking for provisioner in "/usr/bin"
[DEBUG] checking for provisioner in "/home/lukerb/.terraform.d/plugins"

有人知道我哪里犯了错误或者问题到底是什么吗?

编辑:

按照@Matthew Schuchard 的建议进行更改后,我收到了类似的错误

2025-04-08T15:33:07.564+0200 [INFO]  Terraform version: 1.11.3
2025-04-08T15:33:07.564+0200 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2025-04-08T15:33:07.564+0200 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2025-04-08T15:33:07.564+0200 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-04-08T15:33:07.564+0200 [DEBUG] using github.com/zclconf/go-cty v1.16.0
2025-04-08T15:33:07.564+0200 [INFO]  Go runtime version: go1.23.3
2025-04-08T15:33:07.564+0200 [INFO]  CLI args: []string{"terraform", "init"}
2025-04-08T15:33:07.564+0200 [TRACE] Stdout is a terminal of width 120
2025-04-08T15:33:07.564+0200 [TRACE] Stderr is a terminal of width 120
2025-04-08T15:33:07.564+0200 [TRACE] Stdin is a terminal
2025-04-08T15:33:07.564+0200 [DEBUG] Attempting to open CLI config file: /home/lukerb/.terraformrc
2025-04-08T15:33:07.564+0200 [INFO]  Loading CLI configuration from /home/lukerb/.terraformrc
2025-04-08T15:33:07.564+0200 [DEBUG] checking for credentials in "/home/lukerb/.terraform.d/plugins"
2025-04-08T15:33:07.564+0200 [DEBUG] Explicit provider installation configuration is set
2025-04-08T15:33:07.564+0200 [TRACE] Selected provider installation method cliconfig.ProviderInstallationFilesystemMirror("/home/lukerb/.terraform.d/plugins/registry.terraform.io/Mastercard/restapi/1.20.0/linux_amd64") with includes [registry.terraform.io/*/*] and excludes []
2025-04-08T15:33:07.565+0200 [INFO]  CLI command args: []string{"init"}
Initializing the backend...
2025-04-08T15:33:07.565+0200 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2025-04-08T15:33:07.565+0200 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2025-04-08T15:33:07.565+0200 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2025-04-08T15:33:07.565+0200 [TRACE] Meta.Backend: instantiated backend of type <nil>
2025-04-08T15:33:07.565+0200 [DEBUG] checking for provisioner in "."
2025-04-08T15:33:07.567+0200 [DEBUG] checking for provisioner in "/usr/bin"
2025-04-08T15:33:07.568+0200 [DEBUG] checking for provisioner in "/home/lukerb/.terraform.d/plugins"
2025-04-08T15:33:07.568+0200 [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend
2025-04-08T15:33:07.568+0200 [TRACE] backend/local: state manager for workspace "default" will:
 - read initial snapshot from terraform.tfstate
 - write new snapshots to terraform.tfstate
 - create any backup at terraform.tfstate.backup
2025-04-08T15:33:07.568+0200 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
2025-04-08T15:33:07.568+0200 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay
2025-04-08T15:33:07.568+0200 [TRACE] statemgr.Filesystem: read nil snapshot
Initializing provider plugins...
- Finding mastercard/restapi versions matching "1.20.0"...
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider mastercard/restapi: provider
│ registry.terraform.io/mastercard/restapi was not found in any of the search locations
│
│   - /home/lukerb/.terraform.d/plugins/registry.terraform.io/Mastercard/restapi/1.20.0/linux_amd64
terraform
  • 2 个回答
  • 41 Views
Martin Hope
Elarbe
Asked: 2024-09-11 02:25:04 +0800 CST

在 docker 映像构建期间,凭据未从 Azure Keyvault 正确传递

  • 5

我有一个使用 azure.identity 库提供的 DefaultAzureCredential() 函数的 python 脚本。当我登录到具有正确权限的 Azure 帐户并运行脚本时,此脚本在本地运行良好。

我现在想使用存储在密钥保管库中的环境变量从 docker 容器内部运行脚本。据我所知,这应该可行。该映像是通过托管标识构建并推送到我的 Azure 容器注册表的。但是,当我拉取映像并尝试运行它时,我收到以下错误:

default_credential = DefaultAzureCredential()
                         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/azure/identity/_credentials/default.py", line 149, in __init__
    credentials.append(EnvironmentCredential(authority=authority, _within_dac=True, **kwargs))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/azure/identity/_credentials/environment.py", line 70, in __init__
    self._credential = ClientSecretCredential(
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/azure/identity/_credentials/client_secret.py", line 45, in __init__
    raise ValueError("client_id should be the id of a Microsoft Entra application")
ValueError: client_id should be the id of a Microsoft Entra application

我的 yaml 文件如下所示:

parameters:
- name: KVConnection
  type: string
  default: 'read-keyvault'
- name: keyVault
  type: string
  default: 'bi-pv-kv'
- name: containerRegistry
  type: string
  default: 'dcr'
- name: CRconnection
  type: string
  default: 'buildandpushdocker'

steps:
- task: AzureKeyVault@2
  displayName: "Get KV secrets"
  inputs:
    azureSubscription: ${{ parameters.KVConnection }}
    KeyVaultName: ${{ parameters.keyVault }}
    SecretsFilter: '*'
    RunAsPreJob: true
  
- bash: |
    echo "##vso[task.setvariable variable=clientid]$(sp-client-id)"
    echo "##vso[task.setvariable variable=clientcred]$(sp-az-secret)"
    echo "##vso[task.setvariable variable=tenantid]$(sp-tenant-id)"
  displayName: Set environment variables

- task: Docker@2
  displayName: Build Planview image 
  inputs: 
    command: build
    repository: planview
    containerRegistry: ${{ parameters.containerRegistry }}
    identity: ${{ parameters.CRconnection }}
    arguments: '--build-arg AZURE_CLIENT_ID=$(clientid) --build-arg AZURE_TENANT_ID=$(tenantid)
      --build-arg AZURE_CLIENT_SECRET=$(clientcred)'
    tags: | 
      planview

- task: Docker@2
  displayName: Push Planview image 
  inputs: 
    command: push
    repository: planview
    containerRegistry: ${{ parameters.containerRegistry }}
    identity: ${{ parameters.CRconnection }}
    tags: |
      planview

其中是否存在明显的错误或如何改进?服务连接均已正确添加。我尝试将保险库中的确切凭据硬编码到本地运行的本地 dockerfile 中,它也在那里工作,这表明问题实际上是由于未正确处理 3 个机密造成的。

非常感谢任何建议或帮助。

  • 1 个回答
  • 28 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