terraform-template-file

using count.index in terraform?

做~自己de王妃 提交于 2020-07-04 09:09:51
问题 I am trying to generate a bunch of files from templates - I need to replace the hardcoded 1 with the count.index , not sure what format terraform will allow we to use. resource "local_file" "foo" { count = "${length(var.files)}" content = "${data.template_file.tenant_repo_multi.1.rendered}" #TODO: Replace 1 with count index. filename = "${element(var.files, count.index)}" } data "template_file" "tenant_repo_multi" { count = "${length(var.files)}" template = "${file("templates/${element(var

using count.index in terraform?

冷暖自知 提交于 2020-07-04 09:08:38
问题 I am trying to generate a bunch of files from templates - I need to replace the hardcoded 1 with the count.index , not sure what format terraform will allow we to use. resource "local_file" "foo" { count = "${length(var.files)}" content = "${data.template_file.tenant_repo_multi.1.rendered}" #TODO: Replace 1 with count index. filename = "${element(var.files, count.index)}" } data "template_file" "tenant_repo_multi" { count = "${length(var.files)}" template = "${file("templates/${element(var

terraform copy/upload files to aws ec2 instance

谁说胖子不能爱 提交于 2020-06-16 19:54:09
问题 We have cronjob and shell script which we want to copy or upload to aws ec2 instance while creating instance using terraform. we tried file provisioner : but its not wokring , and read this option does not work with all terraform version provisioner "file" { source = "abc.sh" destination = "/home/ec2-user/basic2.sh" } tried data template file option data "template_file" "userdata_line" { template = <<EOF #!/bin/bash mkdir /home/ec2-user/files2 cd /home/ec2-user/files2 sudo touch basic2.sh

I have a CSV and JSON data to parse the input values to the Terraform main file. Here I can able to parse the data using JSON but not with CSV

喜欢而已 提交于 2020-05-24 07:30:50
问题 I have a azure_subnet snippet to create resources like below. locals { csvlist = fileexists(var.csvfile) ? csvdecode(file(var.csvfile)) : [] subnets = length(var.subnets) > 0 ? var.subnets : local.csvlist } resource "azurerm_subnet" "subnet" { lifecycle { ignore_changes = [network_security_group_id] } count = length(local.subnets) > 0 && var.create ? length(local.subnets) : 0 name = local.subnets[count.index].name resource_group_name = var.resource_group virtual_network_name = var.vnet

Commands in user_data are not executed in terraform

和自甴很熟 提交于 2020-01-23 06:55:47
问题 Hi EC2 instance is created, but commands as part of userdata.sh are not gettingexecuted. When I manually connect to EC2 via putty, i found that nginx is not installed in EC2 instance. To verify if the script is getting executed or not I added echo message, but no output is display in command prompt when i run terraform apply. How can i verify if the user-data is getting executed or not? I have installed Terraform in C drive and below script are present in same folder C:/Terraform/userdata.sh,

Resource 'data.template_file.user_data' does not have attribute 'rendered'

北城以北 提交于 2019-12-11 08:14:19
问题 Terraform Version : v0.11.8 Use case Try to terminate the resources using terraform, got error while running output command. Code: output "frontend_rendered" { value = "${data.template_file.user_data.rendered}" } Debug Output module.test.output.test_rendered: Resource 'data.template_file.user_data' does not have attribute 'rendered' for variable 'data.template_file.user_data.rendered' Expected Behavior Termination without any error. Additional Context This issue came after i upgraded

Can you define Kubernetes Services / Pods using YAML in Terraform?

早过忘川 提交于 2019-12-11 00:26:18
问题 I am using the Kubernetes Provider to describe services/pods in Terraform. It can get confusing using the Hashicorp Configuration Language to define kubernetes_pod or kubernetes_service resources because the Kubernetes documentation describes everything in YAML which it means you need to translate it into HCL. Is it possible to define pods as YAML and use them with kubernetes_pod and kubernetes_service resources as templates? 回答1: While Terraform normally uses HCL, this is a superset of JSON

Terraform local-exec provisioner on an EC2 instance fails with “Permission denied”

那年仲夏 提交于 2019-12-04 05:47:39
问题 Trying to provision EKS cluster with Terraform. terraform apply fails with: module.eks_node.null_resource.export_rendered_template: Provisioning with 'local-exec'... module.eks_node.null_resource.export_rendered_template (local-exec): Executing: ["/bin/sh" "-c" "cat > /data_output.sh <<EOL\n#!/bin/bash -xe\n\nCA_CERTIFICATE_DIRECTORY=/etc/kubernetes/pki\nCA_CERTIFICATE_FILE_PATH=$CA_CERTIFICATE_DIRECTORY/ca.crt\nmkdir -p $CA_CERTIFICATE_DIRECTORY\necho \