- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于三种不同的环境,我希望能够根据环境动态设置变量。在下面的示例中,假设实例类型在 dev 和 prod 之间不同。我无法引用 instance_type
在模块内,除非我有 vars.tf
在我的 terraform.tfvars
旁边存档.
我得到的错误是:unknown variable referenced: 'instance_type'. define it with 'variable' blocks
如果是这种情况,那么这个文件不会是 modules/apollo/vars.tf
下的完全相同的文件吗? ?
我以为 modules/apollo/vars.tf
定义模块所需的必要变量。我认为在 env-dev/services/apollo/
下的“根”级别内没有必要这样做.如果有这样做的“更好”的方式,我全神贯注。
├── env-dev
│ └── services
│ └── apollo
│ ├── main.tf
│ ├── terraform.tfvars
│ └── vars.tf # Do i need this?
├── env-test
├── global
├── mgmt
└── modules
├── apollo
│ ├── main.tf
│ ├── user_data.tpl
│ └── vars.tf
└── defaults
└── main.tf
instance_type = "t2.medium"
instance_type = "t2.large"
variable "instance_type" {
description = "EC2 Instance Type"
}
resource "aws_instance" "instance" {
...
instance_type = "${var.instance_type}"
...
}
最佳答案
调整结构,这是我对你的应用的理解。
├── dev
│ └── apollo_terraform.tfvars
├── test
│ └── apollo_terraform.tfvars
├── global
│ └── apollo_terraform.tfvars
├── mgmt
│ └── apollo_terraform.tfvars
├── main.tf, vars.tf, output.tf, apollo.tf, default.tf, etc
└── modules
├── apollo
│ ├── main.tf
│ ├── user_data.tpl
│ └── vars.tf
└── defaults
└── main.tf
apollo.tf
将有源模块代码来使用共享模块
apollo
.
default.tf
的设置相同
terraform plan -var-file=${env}/apollo_terraform.tfvars
关于Terraform - 如何将 tfvars 与模块一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46657905/
对于三种不同的环境,我希望能够根据环境动态设置变量。在下面的示例中,假设实例类型在 dev 和 prod 之间不同。我无法引用 instance_type在模块内,除非我有 vars.tf在我的 te
我正在尝试使用 Terraform 设置一些非常简单的东西,但它给了我一个我以前从未见过的错误。 当我运行 terraform validate -var-file=secrets.tfvars 时,
我是 Terraform 新手,正在编写脚本。以下是我的目录结构 folder ---.terraform ---..terraform.lock.hcl ---main.tf ---terrafor
这个问题在这里已经有了答案: What is the difference between variables.tf and terraform.tfvars? (2 个回答) 2年前关闭。 我一直在
我将通过 Terraform 管理数十个应用程序的 CDN 配置。我有一组 .tf 文件,其中包含所有配置中通用的所有默认常量设置,然后每个应用程序都有自己的 .tfvars 文件来保存其独特的设置。
我有一个非常简单的脚本(下面的脚本),它创建一个由 terraform 服务主体拥有的组,并添加由其用户主体名称 (UPN) 指定的组成员。我想通过在 dev.tfvars 文件中指定多个组和多个组成
以下是我的 AWS terraform 项目的文件夹结构: c:\terraform ├─modules │ └─ec2-fullstacks │ ├─main.tf
variables.tf有什么区别和 terraform.tfvars ?两者都可以为变量定义(赋值)对吗?这两者中定义的变量的范围或行为有什么不同吗?至于给变量赋值,可以用一个来代替另一个吗? 最佳
我在以下位置有这个 terraform.tfvars 文件: root |_prod |_eu-west-2 |_dev |_terraform.tfvars |_
我的目标是通过模块和 TFvar 在 Terraform 中实现日志分析工作区,以便将其用于其他环境 (DTAP)。我正在尝试此测试,但出现错误: 文件夹结构 env-tfvars\mg-sandbo
看来我的 .gitignore 并不像预期的那样正确。 $ git status On branch master No commits yet Changes to be committed:
我有一个像这样的子网模块: module "subnet" { source = "../../azurerm/azurerm-subnet" business_unit
(请注意:收到初步答案后,这个问题似乎不仅仅是传递变量的问题,而是模块化我的配置,请注意在底部我硬编码值但 UI 提示我提供值) Code example here 我有一个项目,我已经分解成以下目录
我确实使用 Azure、Terraform、Ansible、GIT 和 Visual Studio Team Service (VSTS) 设置了基础架构即代码 (IAC) 构建管道。我还在本地计算机
在几个月没有处理基础架构更改之后,我尝试在一台新机器上加载我们的 terragrunt 文件并遇到了几个错误,我找不到解决方案。 基本上看来,terraform.tfvars当有 *.auto.tfv
我有非常简单的管道,带有 Terraform Init、Plan 和 Apply 的经典管道,但是部署在中间失败了,所以我想销毁所有资源......(后端远程位于 Azure blob 容器上所以我在
我是一名优秀的程序员,十分优秀!