Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [terraform]

Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.

0
votes
1answer
12 views

terraform could not escape single quote

I am trying to escape a single quote in my string: ${join("\n",formatlist("%s ansible_host=%s ansible_ssh_common_args='-o ProxyCommand=\"ssh -W %%h:%%p -q cloud-user@%s\"'","${module.compute....
-1
votes
1answer
14 views

Write if statement for Terraform [on hold]

How to write an if statement in terraform to run the following block with different values according to the environment that will be specified in a variable. root_block_device { volume_type = "...
0
votes
1answer
16 views

terraform escape percentual character

I am trying to escape percentual character in my terraform script: "${join("\n",formatlist("%s ansible_host=%s ansible_ssh_common_args='-o ProxyCommand="ssh -W %h:%p -q cloud-user@%s"'","${module....
5
votes
1answer
87 views

Changing variable used for sensitive value in Terraform without rebuilding the resource

I have a Terraform module that sets the administrator password based on a variable admin_password = "${var.local_admin_password}" However, var.local_admin_password is no longer the only place that ...
0
votes
1answer
12 views

Terraform Heroku Automated Certifcate Management

I cannot find any documentation about Heroku's automated certificate management. The terraform documentation for heroku_cert only refers to certificates which are generated manually: # Create a new ...
0
votes
1answer
63 views

Ansible & Terraform DNS creation on Active Directory with nsupdate

I'm trying to create a new DNS record on active directory with the nsupdate module. Both, Terraform and ansible works with key_name & key_secret. If I disable the secure only option on active ...
2
votes
1answer
97 views

Storage account name already exists

When I attempt to run the code at the bottom I get the following error (no matter what I name the storage account) currently its named "functions" but I could call it "bannanas" and it would output ...
0
votes
1answer
71 views

Azure Function, how to upload/deliver the .NET/PS1 payload

I'm trying to create an Azure function in Terraform and obviously upload a test/sample code. So far I have got the below (copied off here) but I dont know how to finish it off in terms of supply a ...
0
votes
0answers
29 views

Does a Vault policy on the path “auth/token/create” give you access to other users tokens

I'm trying to use Terraform to create/maintain vault policies. From reading tutorials it appears I need to have a user policy that allows child tokens to be created. That would include a rule like ...
0
votes
1answer
623 views

Terraform - how to use multiple modules to create temporary ressources

I have created two Terraform modules, each creating a simple AWS instance and then provisioning some software on it with an Ansible playbook. Each module works correctly when running terraform apply ...
1
vote
1answer
111 views

Creating a NAT gateway with Terraform fails with an error

I'm running a private GKE cluster and want to add a NAT Gateway so I can create firewall rules from requests coming from the cluster (by default, the public IP's for all nodes are ephemeral, thus hard ...
0
votes
2answers
55 views

Terraform GCP add VM to existing VPC

I'm starting to learn Terraform (I want to manage my growing GCP infrastructure). I'm trying to do an apparently simple thing -- create a VM in the different Project -- but: I already have a VPC ...
0
votes
1answer
46 views

Terraform multiple environments on aws

So currently i have one VPC and one ec2 instance. I want to have 2 environments (prod and qa) that share the same vpc. I created a module named vpc but i am not sure how to have the vpc shared ...
1
vote
3answers
199 views

terraform execute bash script into instance

What is the way of execute a sh script into ec2 instance when terraform is building resources? I created an ami with some files in directory for execute, if i enter via ssh i can execute file as ...
-1
votes
1answer
34 views

Terraform: cannot retrieve id from azurerm_network_interface

Why is this not working for me? I have seen this code working everywhere but I keep getting the following error. So frustrating... Error: Error running plan: 1 error(s) occurred: * ...
0
votes
2answers
60 views

google_compute_instance_group Creation Issue

I am trying to create an instance group using the example in the terraform doc at https://www.terraform.io/docs/providers/google/r/compute_instance_group.html . resource "...
0
votes
1answer
19 views

Terraform - Adding a new resource instance and resoring terraform state

Suppose I crated an environment using Terraform script, and then I'd like to add another resource of the same type I already have. For example, I have 2 instances of my app VM and I'd like to add ...
0
votes
1answer
43 views

Terraform & GCP: How to get inventory of current disks?

My goal is to utilize terraform's "google_compute_snapshot" feature (https://www.terraform.io/docs/providers/google/r/compute_snapshot.html) to schedule daily snapshots for all disks in a project. ...
0
votes
1answer
54 views

Using Terraform for every region in a given account, find all VPCs and for each VPC enable flow logs

In Terraform how to populate the list of VPC IDs into the map. I want to find all VPCs for every region in a given account and for each VPC enable flow logs.How this can be done using Terraform
0
votes
1answer
64 views

keeping terraform state file in S3\\bucket when deploying kube using kops / terraform

I am deploying a kube cluster using kops/terraform. My Kube's state store in in S3. However I also want to save my the terraform state file to be in S3:\bucket\something.tf instead of a local ...
1
vote
1answer
76 views

Is it worth bothering writing Cloudformation if Terraform exists? [closed]

Sometimes CloudFormation can be too "complicated". Which cases should CloudFormation win over Terraform?
0
votes
1answer
189 views

Terraform: How to reference the subnet created in the vpc module

How would I reference the subnet created in the vpc module in the ec2 module? provider "aws" { region = "us-east-2" } module "myvpc" { source = "terraform-aws-modules/vpc/aws" name = "my-...
0
votes
1answer
453 views

Use a proxy with Terraform

I am unable to use our corporate proxy with Terraform. I configured the following environment variables (I'm under Windows 7): set HTTP_PROXY=http://proxy.company.local:8080 set HTTP_USER=userID set ...
0
votes
2answers
100 views

How to create database user and assign role to it with terraform

I have created sql server and database with terraform now I have to create database user and assign role to it. How I can do it. Please suggest me.
0
votes
1answer
1k views

Deploying to multiple accounts with Terraform?

I've been looking for a Terraform way to be able to deploy to multiple AWS accounts simultaneously in Terraform and coming up dry. AWS has the concept of doing this with Stacks but I'm not sure if ...
1
vote
2answers
51 views

Terraform fails to launch ec2 instance - Suspect lack of IAM rights for checking instance health

Which iam rights are required for terraform to check instance health during aws_instance creation? I'm seeing this error: * aws_instance.myinstance: Error waiting for instance (i-*********) to ...
0
votes
1answer
35 views

How do I avoid repeating myself with Terraform?

I've just started playing with Terraform, and as a starting point I was importing resources from our vSphere cluster - just a simple test environment I have set up to play with some Ansible stuff. I'...
0
votes
1answer
248 views

git clone hangs during clone when using sshpass

Has anyone found sshpass works to set a phassphrase for ssh or git clones? I have a github repo with a deploy key and a passphrase This results in prompt for passphrase as expected and clone upon ...
0
votes
1answer
18 views

What variables (besides HOME) determine from where terraform expects to find the git key for modules with github as a source

What command line option and environment variables control how terraform finds keys for downloading modules from git? When using terraform modules from a git repo I'm running into problems when I ...
0
votes
2answers
145 views

can I use same state file in terraform for multiple terraform files

Suppose in project directory I have 2 .tf files and I want to have same state file for both .tf file. Now if execute plan for one .tf file my state file got updated but when I am trying to execute ...
1
vote
1answer
68 views

Terraform: Use module instance's name inside module

I am using a Terraform module to deploy resources, using separate instances to deploy sets of those resources. I would like to be able to name those resources according to the instance's name. For ...
0
votes
2answers
216 views

Sharing AWS API Gateway resource between Terraform Workspaces?

I've seen Terraform workspaces recommended for managing different stages (staging, production). That seems to work well with most things as you generally create different resources that have the stage/...
0
votes
1answer
81 views

Get file content as a Terraform output

I have a Terraform configuration where I start a systemd service on an AWS EC2 instance. I need to grep that service's log and export it to be a Terraform output. When hello.service is started, it ...
0
votes
1answer
98 views

Destroy existing Terraform without tfstate

A developer set up AWS infrastructure on AWS. He then left, without sharing the tfstate file. We've only stored internal test data so far, so we'd like to tear down the existing infrastructure and ...
0
votes
0answers
73 views

Terraform - Adding a second AWS IAM Policy

I currently have one IAM Role with a Policy attached to it in the following way: data aws_iam_policy_document bucket_access { statement { actions = [ "s3:AbortMultipartUpload", "s3:...
0
votes
1answer
41 views

Terraform interpolation throwing error when using terraform.workspace option

so I am trying to do interpolation i-e with public scheme and terraform.workspace so subnets will dynamically get selected. For that tried merging terraform.workspace with elb_subnets but its throwing ...
0
votes
1answer
420 views

Terraform GCP: Remote execute PowerShell in Windows instance on create

I have made a simple Terraform manifest that successfully initiates a Windows 2016 instance in GCP. As a next step I would like to execute a Powershell script to further configure and install software ...
0
votes
1answer
37 views

terraform IAM vs cloud console IAM

I am using a Terraform google_project_iam_policy resource to manage a number of roles for a project. I have noticed that it does not always remove a member from a role when I am expecting it to - ...
2
votes
1answer
553 views

Get the Index of an Element in a List in Terraform

How can the index of the elements in a list be calculated in Terraform? Example: If we have this variable: variable "domains" { type = "list" default = [ "tftesting.io", "tftesting.co",...
0
votes
1answer
354 views

Creating multiple Azure VM's with Terraform causing issues with OS Disk

First time asking questions here. I'm trying to create multiple azure VM's in terraform using modules and the count function. The issue I seem to be having, is that when it comes to create the OS ...
0
votes
1answer
69 views

Get all AWS resources via cli with some tag

I've set tag Terraform = true to all resources created by Terraform and now I am wondering is it possible to get all AWS resources (VPC, subnets, ec2 etc) via awscli with this tag? How do you manage ...
1
vote
1answer
904 views

Terraform accessing list elements from module output

Let's say I have a module, which generates some ids: module.tf: resource "random_id" "etcdapiserver-id" { byte_length = 4 count = "${var.etcd_apiserver_count}" } ...
0
votes
1answer
41 views

How do I create a TLS certificate based on the AMI instance information and use it for provisioning?

I am trying to create a TLS certificate for server authentication on Docker on a Terraformed system. To create the TLS server certificate I did the following resource "tls_private_key" "master-1" { ...
1
vote
1answer
43 views

terraform aws identity_source

How can I disable the default identity_source when deploying an API Gateway lambda authorizer using terraform? resource "aws_api_gateway_authorizer" "authorizer" { name =...
3
votes
3answers
650 views

Terraform: Choosing credentials for a remote state file

I have existing infrastructure in Terraform and have been using it for a while. Recently I had swapped the AWS credentials of my local laptop (the creds stored in ~/.aws/credentials) and it stopped ...
0
votes
0answers
48 views

restrict terraform destroy on aws ec2 instances

im trying to restrict destroying instances via aws iam policy, i have a custom policy and also the aws full ec2 access policy attached to a user group, which one takes precedence? this is my custom ...
1
vote
1answer
224 views

How to create temporary one-off terraform resources?

I have searched the mailing list and the documentation for how to do this but couldn't find anything. Here's my use case: I have a fairly simple architecture on AWS. Sometimes I want to test one-off ...
0
votes
0answers
51 views

How to set a dynamic path for output artifact from aws_codebuild_project in Terraform?

I am trying to set up an AWS CodeBuild project in Terraform: resource "aws_codebuild_project" "example" { name = "test-project" description = "test_codebuild_project" build_timeout = ...
0
votes
1answer
120 views

Azure | Terraform not working after couple hours of sitting

I am trying to run an example terraform file, it ran fine a few hours ago but now it won't. I have not touched the computer or terraform since it last ran right using terraform plan. I am getting the ...
0
votes
1answer
274 views

How do you tag EC2 instances spawned by ECS in Terraform?

I have an ECS service that spawns some containers: resource "aws_ecs_service" "rocketchat" { name = "rocketchat-ecs-service" cluster = "${aws_ecs_cluster.rocketchat.id}" ...