hjf*_*itz 4 terraform terragrunt terraform-provider-aws terraform-modules
我正在尝试使用(私有)远程 terraform 模块,并尝试将不同的提供程序传递给它。对于远程模块,没有定义提供程序,据我了解,它将使用本地提供程序。
\n我似乎无法让它使用提供者别名 - 这里有一些文件在起作用:
\n# main.tf\nprovider "aws" {\n region = var.aws_region\n\n}\n\nprovider "aws" {\n alias = "replica_region"\n region = var.replica_region\n}\n\nterraform {\n backend "s3" {\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n# s3.tf\nmodule "some-remote-module" {\n source = 'git::ssh.......'\n providers = {\n aws = aws.replica_region\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n每当我计划(使用 terragrunt)时,该区域就是主要 aws 提供程序配置的区域。我也收到以下警告:
\n\xe2\x94\x82 Warning: Reference to undefined provider\n\xe2\x94\x82\n\xe2\x94\x82 on s3.tf line 12, in module "some-remote-module":\n\xe2\x94\x82 12: aws = aws.replica_region\n\xe2\x94\x82\n\xe2\x94\x82 There is no explicit declaration for local provider name "aws" in\n\xe2\x94\x82 module.some-remote-module, so Terraform is assuming you\n\xe2\x94\x82 mean to pass a configuration for "hashicorp/aws".\n\xe2\x94\x82\n\xe2\x94\x82 If you also control the child module, add a required_providers entry named\n\xe2\x94\x82 "aws" with the source address "hashicorp/aws".\n\xe2\x95\xb5\nRun Code Online (Sandbox Code Playgroud)\n我是否错误地传递了提供者?这难道是 terraform 能够做到的吗?我正在使用 terraform 1.3。远程模块没有任何提供程序配置。
\n此消息的最后一段建议您修改子模块以包含以下声明,以便明确表示当您说“aws”时,它意味着hashicorp/aws而不是某个其他名称空间中的提供程序(可能巧合地也称为“aws”):
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这就是错误消息的含义a required_providers entry named "aws" with the source address "hashicorp/aws"。
这使得 Terraform 能够确定(而不是猜测)短名称“aws”在调用模块和被调用模块中引用相同的提供程序。
| 归档时间: |
|
| 查看次数: |
6486 次 |
| 最近记录: |