# cat main.tfprovider "aws" {profile="default"region = "cn-northwest-1"}module "example" {source="./sub_module"image_id = "ami-08af324f69cf03287"instance_type = "t2.micro"}output "private_ip" {value=module.example.private_ip}output "instance_id" {value=module.example.instance_id}...
When working with complex Terraform configurations, it is convenient to specify a group of resources as a single unit using a module. While the virtual network example in this script is simplistic and only saves a few lines of code, it does make thecode more readable. More complex modules ...
}module"zookeeper"{// 一个本地路径必须以./或者../为前缀来标明要使用的本地路径,以区别于使用Terraform Registry路径。source="./modules/zk"}module"kafka"{ source="./modules/kafka"// 由于依赖了zk模块是输出参数,terraform能够分析出来依赖关系,这里无需depends_on参数# depends_on=[ #module.zookeeper...
terraform { required_providers { docker = { source = "kreuzwerker/docker" } } } module "zookeeper" { // 一个本地路径必须以./或者../为前缀来标明要使用的本地路径,以区别于使用Terraform Registry路径。 source = "./modules/zk" } module "kafka" { source = "./modules/kafka" // 由于依赖...
exportTF_CLI_CONFIG_FILE=$HOME/Desktop/terraform/terraform-module-example/.terrafo rmrc 2. 进行初始化 插件下载方式有两种: 通过terraform init自动下载provider 插件; 登入registry.terraform.io手动到GitHub下载,并按照目录结构存放到plugin_cache_dir; ...
是一种特殊的 resource,即 data resource, 声明 data "aws_ami" "example" {}, data "local_file" "foo" { filename = "${path.module}/foo.bar"}, data "template_file" xx {} Provisioner 需要设置 connections Provisioners Without a Resource resource "null_resource" "cluster" 内置Provisioners ...
“基础设施即代码(Infrastructure as Code)”,这里的Code就是对基础设施资源的代码定义和描述,也就是通过代码表达我们想要管理的资源。 Provider:基础设施管理组件 Terraform 通常用于对云上基础设施,如虚拟机,网络资源,容器资源,存储资源等的创建,更新,查看,删除等管理动作,也可以实现对物理机的管理,如安装软件,部署应...
module "example_asg" { source = "../my-modules/terraform-aws-autoscaling/" name = "example-with-lb-asg" # Launch configuration # # launch_configuration = "my-existing-launch-configuration" # Use the existing launch configuration # create_lc = false # disables creation of ...
This module creates a Lambda function, and configures it to be invoked on a schedule. Example 1: Simple cronjob First, write down some simple code to deploy in a file called index.js: exports.handler = function(event, context, callback) { console.log("Lambda function event:", event); ...
For example, you can find the documentation for the Virtual Network module here. From there you can navigate to the source code and see the module's implementation here. Apply the changes with Terraform. Hint: terraform apply -auto-approve. Review the deployed resources in the Azure Portal. ...