我正在处理基础设施配置,所以我将模块称为嵌套。
有我的文件系统树。
??? main.tf
??? modules
??? client.tf
??? in
??? main.tf
Run Code Online (Sandbox Code Playgroud)
我的文件显示如下。
#main.tf
module "my_vpc" {
source = "./modules"
}
# modules/client.tf
provider "aws" {
region = "us-east-2"
}
module "inner" {
source = "./in"
}
# in/main.tf
provider "aws" {
region = "us-east-2"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
output "vpc_id" {
value = "${aws_vpc.main.id}"
}
Run Code Online (Sandbox Code Playgroud)
所以就我而言,我想从 in/main.tf 中的资源创建模块中获取输出。但是当我运行 terraform apply 命令时,没有输出。
我该如何解决这个问题?
我正在 Typescript 中开发一个名为 CopyPostgresql 的 Pulumi ComponentResource。
CopyPostgreSql 是一个 Kubernetes 作业,它将源 Postgresql 数据库的内容流式复制到目标 Postgresql 数据库。CopyPostgreSql 的选项包括属性源和目标。两者都是 DatabaseInput 类型。
export interface DatabaseInput {
readonly port: Input<number>;
readonly user: Input<string>;
readonly password: Input<string>;
readonly host: Input<string>;
readonly dbname: Input<string>;
}
Run Code Online (Sandbox Code Playgroud)
所以,我想使用端口作为另一个组件的另一个属性的值,但另一个属性的类型是 Input<string>。
如何将 Input<number> 类型的值应用(或转换)到 Input<string>?一般而言:在 Pulumi 中,存在与 pulumi.Output.apply 等效的东西,但要转换 pulumi.Input 值?
我正在为由整体和微服务组成的 Web 应用程序实现 IaC。我想在所有微服务前面放置一个内部 HTTP 负载均衡器,但尚未找到任何示例。我查看了Cloud Foundation Toolkit。这里的内部负载均衡器仅支持 TCP/UDP 内部负载均衡器。谷歌的部署管理器样本根本没有提到它!目前,似乎唯一的选择就是从头开始构建 python 模板。
在我跳入那个兔子洞之前,想检查一下是否有可用的工作示例或示例。
google-cloud-platform google-deployment-manager infrastructure-as-code gcp-load-balancer
我目前测试 terraform 的部署,我需要生成一个相当大的子网列表
我发现我可以使用以下块生成我需要的列表
cidrsubnets("10.10.0.0/18", 9, 9, 9, 9, 9, 9, 9, 9, 9)
Run Code Online (Sandbox Code Playgroud)
并为我需要的每个添加额外的新内容。然而,当需要一个大列表时,这很快就会失控,我想知道如何指定所需的子网数量或结束地址或类似的内容来指定我需要的数量,而不是以 100 个新位为例。
谢谢!
我有一个 CloudFormation 堆栈,如下所示,
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"/home/ec2-user/create_db_user.sh" : {
"source" :
"http://s3.amazonaws.com/devops/create_db_user.sh",
"mode" : "000755",
"owner" : "ec2-user"
}
}
...
Run Code Online (Sandbox Code Playgroud)
在我需要将此初始化脚本输出设置为 cloudformation 堆栈之后,我需要在 EC2 实例启动时运行此命令。
我怎么能这样。
amazon-web-services aws-cloudformation devops infrastructure-as-code
我正在尝试找到一种方法来改善 GCP 中的基础设施即代码情况。我的希望是我可以
我希望通过在部署中添加标签,我可以让它自动将这些标签应用到它创建的任何计算资源或负载均衡器。这样,terraform 就可以创建适用于这些标签的防火墙规则。
我是否以错误的方式处理这个问题,或者有什么办法可以做到这一点?这既涉及自动化防火墙规则管理,也涉及清理可能干扰操作的不必要规则。
yaml google-kubernetes-engine terraform kubectl infrastructure-as-code
我正在尝试遍历地图并在aws_codebuild_project. 这是我第一次在 Terraform 中使用循环。我的主要困惑来源是我不知道资源是否必须“支持”循环,或者是否可以在资源内的几乎所有地方进行迭代?
variable "custom_environment_variables" {
type = map(any)
default = {}
}
resource "aws_codebuild_project" "my_project" {
# other props...
environment {
type = "LINUX_CONTAINER"
# more props
# some hardcoded environment_variable
environment_variable {
name = "APP_STAGE"
value = var.app_stage
}
# some dynamic environment_variable
dynamic "custom_environment_variable" {
for_each = var.custom_environment_variables
environment_variable {
name = custom_environment_variable.key
value = custom_environment_variable.value
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码导致此错误:
? Error: Unsupported block type
?
? on ../modules/static_web_pipeline/main.tf line 155, in resource …Run Code Online (Sandbox Code Playgroud) 在 CloudFormation 中使用 Depends On 的最佳实践是什么?我相信从我读到的内容来看,不建议在 Azure 中这样做并尽量减少它的使用。
例如,我想在 ASG 策略和 ASG 组之间建立 DependsOn 关系。
在上图中,您可以看到 ASG Policy 有一个字段AutoScalingGroupName。
因此,ASG 策略取决于 AutoScaling 组的创建。
这两者之间是否存在依赖关系?
amazon-web-services aws-cloudformation infrastructure-as-code
terraform init 初始化成功,下面是我的main.tf
############################################################################
# VARIABLES
#############################################################################
variable "resource_group_name" {
type = string
}
variable "location" {
type = string
default = "eastus"
}
variable "vnet_cidr_range" {
type = string
default = "10.0.0.0/16"
}
variable "subnet_prefixes" {
type = list(string)
default = ["10.0.0.0/24", "10.0.1.0/24"]
}
variable "subnet_names" {
type = list(string)
default = ["web", "database"]
}
#############################################################################
# PROVIDERS
#############################################################################
provider "azurerm" {
}
#############################################################################
# RESOURCES
#############################################################################
module "vnet-main" {
source = "Azure/vnet/azurerm"
resource_group_name = var.resource_group_name
location = var.location …Run Code Online (Sandbox Code Playgroud) 假设我*.tf在 terraform 项目中有多个文件。当我执行 aterraform apply我想知道: