terraform

Build output map in terraform

╄→尐↘猪︶ㄣ 提交于 2020-01-15 05:57:30
问题 I have a list of users to create, a list of sns topics and to create policies to give permissions to users on topics. These are all namespaced against the user... Given: main.tf provider "aws" { region = "eu-west-1" profile = "terraform" } module "topics" { source = "./queues/topics" } module "users" { source = "./users" } module "policies" { source = "./policies" sns_topics = "${module.topics.sns_topics}" } ./queues/topics.tf resource "aws_sns_topic" "svc_topic" { count = "${length(var.sns

unknown token IDENT list error for IP address variable

允我心安 提交于 2020-01-14 10:11:20
问题 I have defined variable in my .tfvars variable as variables.tfvars address_space = ["10.197.0.0/16"] build-windows.tf variable "address_space" { type = list } In build-windows.tf file I get the error as Unknow token ident list? Not sure what I am doing wrong here, I even do not understand why terraform wants me to use the list instead of a string. When I use string I get an error in terraform plan stating that I have to use list. Not going anywhere. Please assist 回答1: The type parameter is a

unknown token IDENT list error for IP address variable

本小妞迷上赌 提交于 2020-01-14 10:11:10
问题 I have defined variable in my .tfvars variable as variables.tfvars address_space = ["10.197.0.0/16"] build-windows.tf variable "address_space" { type = list } In build-windows.tf file I get the error as Unknow token ident list? Not sure what I am doing wrong here, I even do not understand why terraform wants me to use the list instead of a string. When I use string I get an error in terraform plan stating that I have to use list. Not going anywhere. Please assist 回答1: The type parameter is a

terraform conditional resource

邮差的信 提交于 2020-01-14 07:40:13
问题 I have the following and I want to know what I am doing wrong, as I am sure I shouldn't have to double my code just because of a condition. So I want to do: variable "https" { value = true } resource "aws_security_group" "http_instance_sg" { count = "${var.https ? 0 : 1}" ...... } resource "aws_security_group" "https_instance_sg" { count = "${var.https ? 1 : 0}" ...... } resource "aws_elb" "fe_elb" { security_groups = ["${var.https ? aws_aws_security_group.https_instance_sg.id : aws_aws

Set environment variables in an AWS instance

a 夏天 提交于 2020-01-13 10:54:12
问题 I create an AMI in EC2 with terraform with this resource: resource "aws_instance" "devops-demo" { ami = "jnkdjsndjsnfsdj" instance_type = "t2.micro" key_name = "demo-devops" user_data = "${file("ops_setup.sh")}" } The user data executes a shell script that install Java JRE: sudo yum remove java-1.7.0-openjdk -y sudo wget -O /opt/server-jre-8u172-linux-x64.tar.gz --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup

Set environment variables in an AWS instance

柔情痞子 提交于 2020-01-13 10:52:07
问题 I create an AMI in EC2 with terraform with this resource: resource "aws_instance" "devops-demo" { ami = "jnkdjsndjsnfsdj" instance_type = "t2.micro" key_name = "demo-devops" user_data = "${file("ops_setup.sh")}" } The user data executes a shell script that install Java JRE: sudo yum remove java-1.7.0-openjdk -y sudo wget -O /opt/server-jre-8u172-linux-x64.tar.gz --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup

Terraform v0.11.1 : Error downloading modules: Error loading modules: open .terraform/modules/3f10921295c292995128e9e36eb: no such file or directory

泄露秘密 提交于 2020-01-11 07:31:10
问题 I have recently updated my terraform from v0.10.8 to v0.11.1 I am facing awkward issue while running terraform plan, For first time running the command it gives me proper plan in output but while running the same command 2nd time it gives me below error while loading the module. Error downloading modules: Error loading modules: module zookeeper: open .terraform/modules/3f10921295c292995128e9e36ebdfa9f: no such file or directory It looks like some issue of provider or module, But my terraform

using one terraform inventory into another terraform script

大憨熊 提交于 2020-01-07 02:53:08
问题 I am trying to write a seperate terraform script for aws cloudwatch alerts apart from creating aws instances, i want to use terraform inventory of different terraform script which will build aws instances.How to access the inventory of one terraform script and use it in the cloudwatch alerts terraform script? Thank you! 回答1: This is possible if you are using remote state. You will have to use root-level outputs to expose the values you want to be able to access from the second Terraform state

Terraform remote state in Jenkins

久未见 提交于 2020-01-06 06:51:34
问题 am working on a declarative Jenkins pipeline for Terraform deployments. I want to have the terraform state stored remotely in my s3 I get an error terraform apply -input=false ow.plan [31mFailed to load Terraform configuration or plan: open ow.plan: no such file or directory Any suggestions? Here's my code: pipeline { agent any tools { "org.jenkinsci.plugins.terraform.TerraformInstallation" "terraform" } parameters { choice(name: 'action', choices: 'create\ndestroy', description: 'Create

Terraform external data in metadata_startup_script

痞子三分冷 提交于 2020-01-06 06:36:27
问题 I'm going to parsing a token value from other .tf file into other .tf file I have tried to understand this link and also from this article data.tf data "external" "get_token" { program = ["/bin/sh", "${path.module}/get-token.sh"] } get-token.sh #!/bin/bash token=$(kubectl -n kube-system exec [POD_NAME] cat /var/lib/kube-proxy/kubeconfig 2>/dev/null | grep token | awk '{print $2}' proxy.tf ... metadata_startup_script = <<-EOT - name: kube-proxy user: token: ${lookup(data.external.get_token