terraform

Schema modification giving partitioning error

故事扮演 提交于 2020-05-17 06:24:07
问题 I have previously created a table in bigquery using following script in terraform resource "google_bigquery_dataset" "my-dataset" { dataset_id = "datasetname" description = "description" } resource "google_bigquery_table" "mytable" { dataset_id = google_bigquery_dataset.my-dataset.dataset_id table_id = "mytable" time_partitioning { type = "DAY" } schema = <<EOF [ { "name": "field_one", "type": "STRING", "mode": "NULLABLE" }, { "name": "field_two", "type": "RECORD", "mode": "NULLABLE", "fields

terraform: create list based on resource count

偶尔善良 提交于 2020-05-17 05:25:33
问题 We have a bunch of instances (I know... cattle, not pets, but in this case, these are really pets) resource "aws_instance" "read_00" { count = "${var.read_00_count}" resource "aws_instance" "read_01" { count = "${var.read_01_count}" And we have an ELB where we want to dynamically add the instances based on their count variable, like so: resource "aws_elb" "read_slaves" { instances = ["${aws_instance.read_.*.id}"] But that doesn't work, of course. Is it possible to dynamically create a list of

how to deploy a specific tf file in terraform

爱⌒轻易说出口 提交于 2020-05-15 08:01:06
问题 I have 3 .tf files in my terraform root directory: vpc.tf subnets.tf instances.tf Along with the .terraform directory after running terraform init I would like to deploy only vpc.tf running something like: terraform apply vpc.tf #here, vpc.tf is a terraform file But it doesn't work (I get a Go error: "zip: not a valid zip file"). If I just run terraform apply it will try to apply all configurations in all 3 terraform files (vpc.tf, subnets.tf and instances.tf) which is not what I want. It

Terraform - how to use for_each loop on a list of objects to create resources

跟風遠走 提交于 2020-05-14 18:44:27
问题 I have an object containing the list of subnets I want to create. variable "subnet-map" { default = { ec2 = [ { cidr_block = "10.0.1.0/24" availability_zone = "eu-west-1a" } ], lambda = [ { cidr_block = "10.0.5.0/24" availability_zone = "eu-west-1a" }, { cidr_block = "10.0.6.0/24" availability_zone = "eu-west-1b" }, { cidr_block = "10.0.7.0/24" availability_zone = "eu-west-1c" } ], secrets = [ { cidr_block = "10.0.8.0/24" availability_zone = "eu-west-1a" }, { cidr_block = "10.0.9.0/24"

AWS on Terraform - How to avoid 'forces new resource'

核能气质少年 提交于 2020-05-13 14:34:06
问题 I'm using Terraform to launch my cloud environments. It seems that even minor configuration change affects many of the resources behind the scenes. For example, In cases where I create AWS instances - a small change will lead to auto-generation of all the instances: -/+ aws_instance.DC (new resource required) id: "i-075deb0aaa57c2d" => <computed> (forces new resource) <----- How can we avoid that? ami: "ami-01e306baaaa0a6f65" => "ami-01e306baaaa0a6f65" arn: "arn:aws:ec2:ap-southeast-2

Iterate over list of list of maps in terraform

岁酱吖の 提交于 2020-05-13 06:32:06
问题 Consider I have a variable that is a list of list of maps. Example: processes = [ [ {start_cmd: "a-server-start", attribute2:"type_a"}, {start_cmd: "a-worker-start", attribute2:"type_b"} {start_cmd: "a--different-worker-start", attribute2:"type_c"} ], [ {start_cmd: "b-server-start", attribute2:"type_a"}, {start_cmd: "b-worker-start", attribute2:"type_b"} ] ] In each iteration, I need to take out the array of maps, then iterate over that array and take out the values of the map. How do I

Iterate over list of list of maps in terraform

半世苍凉 提交于 2020-05-13 06:27:49
问题 Consider I have a variable that is a list of list of maps. Example: processes = [ [ {start_cmd: "a-server-start", attribute2:"type_a"}, {start_cmd: "a-worker-start", attribute2:"type_b"} {start_cmd: "a--different-worker-start", attribute2:"type_c"} ], [ {start_cmd: "b-server-start", attribute2:"type_a"}, {start_cmd: "b-worker-start", attribute2:"type_b"} ] ] In each iteration, I need to take out the array of maps, then iterate over that array and take out the values of the map. How do I

Terraform - AWS auto generated IAM role

浪子不回头ぞ 提交于 2020-05-12 04:57:43
问题 I am using Terraform to construct our applications infrastructure, its been executed from a container. At the beginning I have attached a IAM (AWS) role which basically provide the container with Admin permissions (which is a mistake, i know). Now i need to create a role that is minimal for the existing state. I have a lot of services and resources in that terraform plan. Is there a tool that can read a state or a plan and generate a list of necessary IAM policies? Or what would be the best

Terraform (2) 资源与变量

浪尽此生 提交于 2020-05-07 02:02:06
  《 Windows Azure Platform 系列文章目录 》    熟悉Azure Template的读者都知道: Azure ARM (5) ARM Template初探 - 本地JSON Template文件(1)   Azure Template分为两种类型的文件,资源和变量   (1)Template:资源文件,表示我们需要创建的资源是什么,比如Azure VM,Azure Storage   (2)Parameter:变量文件,表示资源所使用到的参数,比如虚拟机的名字,登陆虚拟机所需要的用户名和密码。存储名称等等。   在使用Terraform时,也会有两种类型的文件。我们以Terraform例子为例:    https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples/virtual-networks/multiple-subnets    Terraform 运行时会读取工作目录中所有的 *.tf, *.tfvars 文件,所以我们不必把所有的东西都写在单个文件中去,应按职责分列在不同的文件中,例如:   provider.tf -- provider 配置   terraform.tfvars -- 配置 provider 要用到的变量  

Terraform (1) 安装与配置

♀尐吖头ヾ 提交于 2020-05-06 17:35:40
  《 Windows Azure Platform 系列文章目录 》    本文将介绍如何安装与配置Terraform,并构建与Azure China环境的链接   1.笔者的环境是Windows 10 Sub System for Linux (WSL),有关WSL环境的安装与配置,不在此文中赘述。   2.安装完WSL后,我们安装unzip工具 sudo apt install unzip   3.下载Terraform, https://www.terraform.io/downloads.html wget https: // releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip   4.unzip terraform unzip terraform_0. 12 .24_linux_amd64. zip   5.移动文件terraform到/usr/bin目录 mv terraform /usr/bin   6.查看版本 terraform version   7.Terraform安装完毕后,我们需要在WSL中设置azure cli,具体参考: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-apt