Questions tagged [terraform]

For questions about Terraform, an open source tool to maintain infrastructure.

Filter by
Sorted by
Tagged with
0
votes
1answer
6 views

Terraform and Kubernetes' StorageClass with node affinity

Im able to make a number of kubernetes constructs in terraform and even have done so for my ephemeral stateful data that requires low latency disk performance. I can terraform up a ...
0
votes
1answer
15 views

How to get VPC id in Terraform module?

I have a module structure like module "vpc" { source = "./modules/vpc" } module "prod_subnets" { source = "./modules/vpc/modules/subnets/production" } when running am getting an error like [0m on ...
1
vote
1answer
14 views

Creating ec2 instances and installing mongoDB using automation

I am trying to create a 3 node MongoDB replica set using automation (ansible or terraform) in AWS. I am able to do this in the management console of AWS, but I'm not sure how to approach it. ...
1
vote
1answer
12 views

Is it possible to create a module that either creates a resource or sources a data source, based on a boolean value?

Basically, what I'd like to do is create a module that does this pseudocode: if <boolean> then resource "<resource type>" "name" { # ... set variables ... } else { data "<...
0
votes
0answers
16 views

Terraform | Auto-scaling elasticache_replication_group Redis on AWS

Wanted to ask a question regarding auto-scaling of the redis replication_group I created using terraform. The situation is that I am provisioning a new redis cluster using terraform. But as the ...
0
votes
0answers
7 views

terraform map that has a key itself set as a value from another map?

Im trying to set the name of the key itself (not its value) from the value of another key from another map. So if I I were to have this: variable "map1" { type = map default = { "RGs" = { "RG1" = { "...
1
vote
1answer
35 views

Terraform error Reference to “count” in non-counted context for resources not necessarily data

here's my part of my code that I am having issues with. Unfortunately I could not understand the relationship between the last answer, despite being almost what I need, and my situation. data "...
1
vote
2answers
21 views

Terraform - how to modify a existing S3 bucket that was created from module?

I already have my S3 bucket called foo-name created and existing with terraform. I want to modify the existing s3 bucket and a policy. But when I do this it seems to want to add a new s3 bucket ...
1
vote
1answer
46 views

Correct way to handle 'optional' array of resources in Terraform

In one of our our Terraform modules we have a variable to optionally create a load balancer. As part of this we create some subnets thusly: resource "aws_subnet" "subnet_loadbalancer" { count = var....
0
votes
1answer
16 views

Error when creating new recource using backend AWS s3 [closed]

When I try create a new resource using terraform apply (Terraform init was success) received an error: data.terraform_remote_state.environment_data: Refreshing state... Error: Unable to find remote ...
2
votes
2answers
25 views

Terraform's local state (the 2 tfstate files) contain very sensitive info

Part of my IaC that describes my systems for Azure is CosmosDB, and Keyvaults. Terraform happily created everything and I was able to use an output from CosmosDB (db keys) as an input to the Keyvault ...
0
votes
0answers
31 views

Using terraform and Kubernetes: Who/what is responsible for backup restoration after all databases are down?

I'm kinda new to the DevOps scene, doing my first job in half a month and I'm currently reading up on terraform/kubernetes. I'm thinking of a scenario where all the infrastructure concerning data ...
0
votes
0answers
17 views

Does terraform scffold handle maps of json data differently?

I converted aws_s3_bucket_policy and aws_iam_policy_document to scaffold but now the `aws_s3_bucket_policy is changing as it is escaping new lines. In both, I had used "{$data....
1
vote
1answer
39 views

Terraform: can't connect to AWS provider using shared config file or static variable

I'm trying to use terraform to manage AWS resources and trying to set up the credentials configuration. I'm following the official documentation: https://www.terraform.io/docs/providers/aws/index.html ...
0
votes
1answer
26 views

validation block iteratively

This validation block works for a single input variable. variable "mytestname" { validation { condition = length(regexall("test$", var.mytestname)) > 0 error_message = "...
4
votes
2answers
49 views

How to `terraform destroy` an `aws_instance` without also destroying its `aws_ebs_volume` (separate resource)

$ terraform -version Terraform v0.12.21 + provider.aws v2.34.0 Given a terraform configuration for one set of single aws_instance, aws_ebs_volume and aws_volume_attachment resources, each named, say,...
0
votes
0answers
7 views

Is vsphere terraform provider working with vsphere 5.5?

Is vsphere terraform provider working with vsphere 5.5? I didn't find any information in Hashicorp documentation about the version compatibility... Thanks in advance!
1
vote
1answer
32 views

AWS launch template create-before-destory?

In terraform, to reduce downtime when creating a new auto-scaling-group behind an existing load balancer, you can use a launch configuration and set create-before-destroy. Launch templates are the ...
0
votes
0answers
14 views

Why does destroying an ASG AWS take so long?

Creating an auto-scaling-group in AWS is extremely fast in terraform. Destroying one, on the other hand, takes far longer (5+ minutes instead of 1 minute). This makes down-time fairly significant (...
1
vote
1answer
38 views

Cloud agnostic infrastructure automation better than terraform?

Are there any infrastructure automation technologies which do a better job at being portable than terraform? We heavily leverage terraform as it is a cloud-agnostic technology (vs, say, ARM templates ...
0
votes
0answers
28 views

InvalidVpcID.NotFound while VPC is created

I have a fairly simple Terraform script for AWS, based on an example from the terraform site. Whenever I run this I get an error: Error: error attaching EC2 Internet Gateway (igw-xxxxx): Error ...
1
vote
1answer
52 views

Mount Azure FileShare using terraform

What is a good way to mount an Azure File Storage automatically during provisioning on VMs? There is a Microsoft doc describing how a file share can be mounted in general. This requires that Azure ...
1
vote
1answer
120 views

Terraform 0.12 - For each subnet-id in array, get cidr_block

I have a list of subnets IDs and I want to get an array of the cidr_blocks associated to each subnet. variable "aws_subnet_ids" { type = list(string) default = ["subnet-aaaaaaaa","subnet-bbbbbbbb"...
0
votes
3answers
41 views

How to send local files using Terraform Cloud as remote backend?

I am creating AWS EC2 instance and I am using Terraform Cloud as backend. in ./main.tf: terraform { required_version = "~> 0.12" backend "remote" { hostname = "app.terraform.io" ...
0
votes
0answers
28 views

Managing environment specific properties of infrastructure with Terraform

(Re-posted also to StackOverflow) TL;TR: Assume there are dev, stage and prod environments of Web server infrastructure coded with Terraform. How to ensure each environment runs on different domain ...
0
votes
0answers
9 views

vSphere Provider for Terraform - Not loading due to TFTP - File Not Found

I am using the test deploy for the vSphere provider on the terraform website here: https://www.terraform.io/docs/providers/vsphere/index.html When the VM boots up, however, I get the following error: ...
1
vote
1answer
201 views

How to create dependency between modules in terraform

I have 2 modules A and B. I want a particular resource in module B to be created only after a particular resource in module A is completed completely. I was trying to achieve just that with this as ...
1
vote
1answer
30 views

Calling a Terraform object in seperate folder

I need to reference my VNET Gateway residing in an infrastructure folder, in a VPN folder in order to connect a VPN utilising a Local Network Gateway, but these could be any object in Azure for the ...
3
votes
2answers
89 views

What is the most used tool for Cloud Infrastructure deployment Ansible vs Puppet vs Terraform?

I have some time for research at work right now, and I was thinking on expanding my knowledge on my favorite subject, which is DevOps (love you all). I have some advanced experience with Ansible, as ...
1
vote
0answers
55 views

How to connect AWS LoadBalancer to EKS node group using Terraform?

I've created the following service using Terraform: resource "kubernetes_service" "example" { metadata { name = "example" labels = { app = "example" } } spec { port { ...
0
votes
0answers
13 views

Importing non-default workspaces in Terraform

I'm having a bit of trouble with Terraform. I have a Terraform project which is shared by a few developers and uses non-default workspaces (i.e. named workspaces, not the default one). I would like ...
0
votes
1answer
66 views

Why does my Terraform config require variables in multiple places?

My folder hierarchy looks like this: / -> live/ : main.tf : variables.tf -> modules/ -> logs/ : logs.tf : variables.tf In my main.tf I have: module "logs" { ...
0
votes
2answers
48 views

How can I find out when Terraform will support newly released AWS services?

For example, AWS announced their new "RDS Proxy" service at re:Invent 2019 and it is now in preview. How can I find out when/if Terraform will support this (for planning purposes)? https://aws.amazon....
0
votes
0answers
18 views

How to handle oauth2 in dynamic environments?

We have a DevOps pipeline supporting 2 services with dynamic environments, where we use Terraform to provision each service independently through a parametrization based on the git's ref that it is ...
1
vote
2answers
172 views

How to create databases, users and grants with terraform mysql and output the created credentials?

For a new deployment I want to create databases, users and grants on a previous created MySQL database on azure. The following code used inside a module creates the environment as expected and I ...
1
vote
1answer
21 views

Having some trouble getting service running with Docker and Terraform

I'm very new to DevOps but I'm trying to learn some of it a bit. I'm working with Terraform, trying to get a service to run on AWS using Fargate and Docker. I've successfully set up my ECR ...
1
vote
1answer
236 views

How to set Terraform Cloud environment variables from the command line?

Terraform Cloud is a SaaS platform for managing Terraform runs, state and variables. Once you have created a project you can set environment variables via the following page: https://app.terraform....
0
votes
1answer
48 views

Unable to understand the logic behind this terraform function

So i was going through a code of some one else and just could not make sense of it,, if may be some can of this, "${replace(jsonencode(list(local.cadvisor_container_definition)), "/\"(\\d{2,5}|true|...
0
votes
1answer
99 views

Use Terraform to manage ssh-keys in GCE

I use Terrafrom and manage access to VMs in GCE by changing VM metadata. Before I put it to string, but it not good, so I try to put them to variable and use it. But I faced problem. This is my code: ...
1
vote
2answers
33 views

how long does it take to deploy a serverless function?

using any method - cli, serverless.com, terraform, roughly: how much time can i expect to pass between these two steps: submitting a new function to AWS (or azure or GCF), and having that function ...
0
votes
1answer
49 views

Where do I use Ansible and where is Terraform used? ( Strengths & Weaknesses) [closed]

What is Ansible mainly used for? Where do I use Terraform? This question focusses on where the tools have relative strengths or weaknesses. For example: Ansible for VM build and Software ...
1
vote
1answer
386 views

How do I enter a multi line variable in Terraform?

It's for the public key variable for testing lab enviroments in my variables.tf file I tried <<EOF the string EOF but terraform dosn't seem to like that
1
vote
1answer
325 views

Terraform creating single SG but multiple CIDR blocks

I am trying to use Terraform to create a single security group that will allow traffic for mongo on port 27017 from all my private subnets that are stored in a variable. My issue is I am unsure how ...
1
vote
2answers
87 views

Given a blank slate, tool recommendations? [closed]

so I have 8 months of DevOps experience previously working as a desktop engineer for two and a half years.Starting a new role in the education sector, recently they brought their IT department which ...
2
votes
1answer
415 views

How to specify specific subnet in Terraform when using for each

I am trying to create an ec2 instance that will hold my Jenkins server. I want this to be in a private subnet which I created using a for each loop. Below is my subnet for each loop and my ec2 ...
1
vote
1answer
352 views

Module directory modules/queues.tf does not exist or cannot be read

I am trying to setup terraform with modules and when doing terraform init after creating a module I have ran into an issue where I am told it does not exist or can't be read. I've checked many times ...
0
votes
0answers
11 views

How to grant the currently authenticated AzureAD Service Principal to a newly created Azure Key Vault?

When creating an Azure KeyVault instance in a subscription, we want to create an azurerm_key_vault_access_policy that grants the Service Principal that Terraform is authenticating as Set and Delete ...
1
vote
1answer
74 views

How can I enable active tracing by default for an AWS Lambda function using Terraform?

On the console, there’s the option to enable active tracking for X-ray tracking but I can see this in the Terraform aws_lambda_function resource the aws_xray_sampling_rule resources? I'm currently ...
0
votes
0answers
202 views

Issue running terraform plan using Azure provider

I have the following terraform statement (see below), howeve I am unable to run terraform plan. Is this an account issue or a code issue? # Configure the Microsoft Azure Provider. #provider "azurerm" ...
3
votes
1answer
19 views

Provisioning a server on behalf of a user on GCP/AWS/Azure and probably relinquish access

I'd like to build a service where I run a custom setup script on behalf of a user on an t2.micro equivalent instance but be able to probably relinquish access to the server. Any advice on the tech ...