嘿,团队我\xe2\x80\x99m 在文档中找不到有关如何在 JSON 文件中添加 terraform 变量的信息,
\n我需要在这个 JSON 中注入这个变量,
\n
在这个形状的 JSON 中,但它不起作用,
\n
我确实尝试过使用 var 和 locals,我尝试过使用 var 和 locals,但它不起作用,它是默认的
\njson amazon-web-services grafana terraform terraform-provider-aws
Terraformgoogle_cloudfunctions_function资源文档将秘密环境变量列为可选参数。我要么没有正确使用它,要么与文档相反,它实际上不受支持。
resource "google_cloudfunctions_function" "function" {
name = var.function_name
runtime = "nodejs16"
available_memory_mb = 128
source_archive_bucket = google_storage_bucket.bucket.name
source_archive_object = google_storage_bucket_object.zip.name
trigger_http = true
entry_point = var.function_entry_point
secret_environment_variables = []
}
Run Code Online (Sandbox Code Playgroud)
结果是:
错误:modules/cloud-function/main.tf 第 51 行不受支持的参数,在资源“google_cloudfunctions_function”“function”中:51:secret_environment_variables = {} 此处不需要名为“secret_environment_variables”的参数。您的意思是定义一个“secret_environment_variables”类型的块吗?
这是以下结果terraform version:
Terraform v1.1.9
on darwin_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/google v4.18.0
Run Code Online (Sandbox Code Playgroud) 我是 Terraform 的新手,仍在研究文档,尚未找到一种方法来适应我需要实现的特定解决方案的设置,并希望某种灵魂能够能够推动我朝正确的方向前进。
我正在尝试管理一组参数化模板,这些模板部署支持我们在 GCP 中开发的新应用程序所需的一切。我想要实现的目标是能够将这些模板部署到三个不同的环境,每个环境本身都位于不同的 GCP 项目中。
根据建议,该计划是运行 terraform 并传入
a) 特定的 .tfvars 文件取决于部署到的环境/项目 (dev/test/prod)。
b) 使用 -chdir 参数告诉 Terraform 从“infra-common”文件夹中获取所有模板。
棘手的部分是我们希望每个环境(gcp 项目)在 gcs/storage 中托管它自己的状态文件。
我一直在研究工作区,但工作区似乎只会在单个后端上创建状态子文件夹。
问题:可以这样做或者有更好的方法吗?
谢谢!
我正在尝试执行此文件中定义的代码:
但是,当我尝试获取 object_id (data.azurerm_client_config.current.object_id) 时,我发现该值为空。因此,我无法进一步设置访问策略。
现在查看其他人关于空 object_id 的帖子,它说这是由于 Azure CLI 的更改所致。
鉴于此,如何为当前客户端设置密钥保管库中的访问策略?
我试图找出在特定条件下在 terraform 中设置 helm 值的最佳方法是什么。例如,我希望下面的代码片段仅在特定用例中执行。否则,我希望 Terraform 忽略它。我的用例是,我想让最终用户运行此 Terraform 来选择是否要配置内部 Azure LB 还是常规 LB。如果是常规的——也在代码中创建的公共 IP 将在值中设置。如果是内部 - Azure 将自动生成一个私有 IP 并将其设置为 LB 的“外部 IP”。
set {
name = "controller.service.loadBalancerIP"
value = mypuclicip
}
Run Code Online (Sandbox Code Playgroud)
知道我怎样才能实现它吗?
我们在 Terraform 中使用 helm 提供程序来配置 istio 入口网关,该网关在后端使用此图表
下面是提供相同内容的 terraform 代码片段。请帮助覆盖默认图表值以创建内部负载均衡器而不是默认的外部负载均衡器。我们知道可以通过更新清单文件中的注释来完成。但不确定如何在 terraform 代码片段中执行相同的操作?
terraform {
required_providers {
helm = {
source = "hashicorp/helm"
version = ">= 1.0.0"
}
}
}
provider "helm" {
kubernetes {
config_path = "${var.kubeconfig_file}"
}
}
resource "helm_release" "istio-ingress" {
repository = local.istio_charts_url
chart = "gateway"
name = "istio-ingress-gateway"
namespace = kubernetes_namespace.istio_system.metadata.0.name
version = ">= 1.12.1"
timeout = 500
cleanup_on_fail = true
force_update = false
depends_on = [helm_release.istiod]
}
Run Code Online (Sandbox Code Playgroud) 我试图防止 terraform 中的存储桶被删除。该存储桶保存我的 terraform 远程状态文件。到处都说要用lifecycle_configuration=prevent_destroy。terraform 文档说使用新参数aws_s3_bucket_lifecycle_configuration。我有这样的设置:
# Prevent deletion\nresource "aws_s3_bucket_lifecycle_configuration" "tf_remote_state_s3_lifecycle_config" {\n bucket = aws_s3_bucket.tf_remote_state.id\n rule {\n id = "prevent_destroy"\n status = "Enabled"\n }\n \n}\nRun Code Online (Sandbox Code Playgroud)\n我收到此错误:
\n\xe2\x95\xb7\n\xe2\x94\x82 Error: error creating S3 Lifecycle Configuration for bucket (XXXX): InvalidRequest: At least one action needs to be specified in a rule\n\xe2\x94\x82 status code: 400, request id: XXXX, host id: XXXX\n\xe2\x94\x82 \n\xe2\x94\x82 with aws_s3_bucket_lifecycle_configuration.tf_remote_state_s3_lifecycle_config,\n\xe2\x94\x82 on main.tf line 34, in resource "aws_s3_bucket_lifecycle_configuration" "tf_remote_state_s3_lifecycle_config":\n\xe2\x94\x82 34: resource "aws_s3_bucket_lifecycle_configuration" "tf_remote_state_s3_lifecycle_config" {\n\xe2\x94\x82 …Run Code Online (Sandbox Code Playgroud) 我有一个简单的地形配置,如下所示。
\n# Terraform settings Block\nterraform {\n required_version = "~> 1.0.0"\n required_providers {\n azurerm = {\n source = "hashicorp/azurerm" # https://registry.terraform.io/providers/hashicorp/azurerm/latest\n version = "~> 3.0"\n }\n }\n}\n\nprovider "azurerm" {\n features { }\n}\n\nresource "azurerm_resource_group" "rg" {\n name = var.resource_group_name\n location = var.resource_group_location\n}\nRun Code Online (Sandbox Code Playgroud)\n当我跑步时
\nterraform init\nRun Code Online (Sandbox Code Playgroud)\n我收到以下错误。
\n\xe2\x95\xb7\n\xe2\x94\x82 Error: Unsupported Terraform Core version\n\xe2\x94\x82\n\xe2\x94\x82 on main.tf line 3, in terraform:\n\xe2\x94\x82 3: required_version = "~> 1.0.0"\n\xe2\x94\x82\n\xe2\x94\x82 This configuration does not support Terraform version 1.2.2. To proceed, either choose another supported …Run Code Online (Sandbox Code Playgroud) 尝试运行时,我使用 Terraform AWS Provider 收到以下错误terraform plan。仅当在 GitHub Actions 上运行时才会发生这种情况(在本地工作正常)
配置 Terraform AWS Provider 时出错:无法获取共享配置文件
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.22"
}
}
required_version = ">= 1.1.7"
}
Run Code Online (Sandbox Code Playgroud)
如果我降级到version = "~> 3.0"它就可以解决问题。但我想升级到最新版本。
有没有办法让它在 CI 上运行?
我从 GitHub 工作流程调用了 Terraform,其中的步骤之一是 RDS 更新。状态的后端是 S3 存储桶。Terraform 正确反映了更新的状态(请参阅下面的日志),但根本没有反映对 RDS 数据库实例的更改。
以下是 terraform apply 操作的输出 -
我还注意到状态文件没有更新回 S3。有趣的是,如果我更改实例的名称(强制销毁并重新创建),terraform 就会按预期工作。
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# aws_db_instance.app_db will be updated in-place
~ resource "aws_db_instance" "app_db" {
id = "app-tf-rds"
~ instance_class = "db.t3.medium" -> "db.t3.small"
name = "myappdb"
# (57 unchanged attributes hidden)
}
Plan: 0 to add, …Run Code Online (Sandbox Code Playgroud)