Questions tagged [terraform]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

How to reference a state file in one module from another, when using dynamic names

I have a Terraform/Terragrunt project to automate the creation of and ECR repository and several Fargate instances (test, uat, production) to host images from that repository (depending on how far ...
2
votes
1answer
16 views

Are manual changes to an aws IAM policy detected by Terraform plan?

I know that Terraform dose some checks before the plan and can detect some changes but not others such as detecting changes to variables on a lambda but not detecting a new secret in a secret manager. ...
1
vote
0answers
10 views

Terraform fails on creating network with libvirt provider

I wanted to spin up a test environment locally using the description from this stackoverflow answer: https://stackoverflow.com/a/58607900/4397899 The main.tf looks like ##############################...
1
vote
0answers
20 views

Terraform duplicates the security groups, how do I stop it?

I'm using terraform to create two instances and a security group. Here is how I did it: # bastion host resource "aws_instance" "bastion_1a" { ami = data.aws_ami....
0
votes
0answers
10 views

Automating puppet master deployment with r10k

I am looking to automate the process of standing up and tearing down a development environment. Puppet currently manages the production and staging systems. I am looking to leverage r10k to populate ...
1
vote
3answers
38 views

Run integration test with ansible playbook using terraform provisioning

Ok so I am totally new to devops! I am an experienced developer, but at my new job I have been tasked to automate CI/CD. Non-existing so far. Only CI with Travis. So the ideal workflow is: Push to CI ...
1
vote
1answer
32 views

Troubleshooting VPC flow logs with an S3 bucket using SSE-KMS encryption with CMK

I'm using Terraform and trying to set up automatic export of VPC flow logs into an S3 bucket in the same AWS account and region (ca-central-1) that has default encryption turned on with AWS-KMS (using ...
1
vote
2answers
89 views

How do we move to a modern CICD approach

This may also be a general pulse; but here lies the issue We use EKS, we have Jenkins, we have Ansible, we have Terraform, we have BitBucket; but none of these really form a pipeline and I'm stuck ...
1
vote
0answers
28 views

secret id in docker terraform file

what value secret_id variable is referring in below main.tf and terraform.tfstate code There is no variable called "id" in my secrets.tf file main.tf resource "docker_service" "mysql-service" {...
1
vote
3answers
85 views

Terraform syntax error after V0.12 upgrade

I have just upgraded from terraform v0.11 to v0.12 But i am facing lot of error complete code @ https://github.com/sivatest82/Terraform1/tree/master/secretsv12 especially in the block secrets = [ ...
1
vote
1answer
28 views

Terraform fails to modify DNS settings a recently created VPC Peering connection because it is not yet active

I have the following configuration file: environment/main.tf: resource "aws_vpc_peering_connection" "sb_vpc_peering" { vpc_id = var.vpc_id peer_vpc_id = var.peer_vpc_id peer_region = var....
0
votes
0answers
10 views

How do I give an Azure Container Group a static IP within a Virtual Network?

These are my requirements: I need to do orchestration on a set of containers and I need to use Azure but I can't use Kubernetes (AKS). After some research it seems like Azure Container Instances ...
1
vote
1answer
37 views

Terraform conditionally create VPC

I am in the process of creating a terraform template, part of which can create a VPC. The user has the option to specify the parameter create-vpc. This will be passed to the module https://github.com/...
1
vote
2answers
150 views

Terraform get list index on for_each

Terraform newbie here. I'd like to iterate a list using for_each, but it seems like the key and value are the same: provider "aws" { profile = "default" region = "us-east-1" } variable "...
1
vote
3answers
150 views

How do I run Terraform with AWS MFA?

I'm using Terraform with the terraform-provider-aws provider to manage my AWS infrastructure. I'm trying to enable mfa_delete on an S3 bucket, but when I try to apply the change I get this error: 1 ...
1
vote
2answers
86 views

How to use terraform import with module

Terraform v0.11.11 We have a quite big aws setup created with Terraform. Different regions are applied separately and that why we have most of the things in modules which are imported like this: ...
0
votes
1answer
24 views

Referencing locally built Docker images in Terraform

Is it possible to use docker images in Terraform that are not hosted in a registry but in the local Docker storage? I'd like to have a resource like the following where no pull is performed on the ...
1
vote
1answer
23 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 ...
1
vote
1answer
114 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 ...
2
votes
1answer
25 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. ...
2
votes
1answer
18 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
24 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
186 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 "...
2
votes
2answers
54 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
74 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
47 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
30 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
20 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....
2
votes
1answer
168 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
31 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
73 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,...
1
vote
1answer
65 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
23 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 (...
2
votes
1answer
50 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 ...
1
vote
1answer
188 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 ...
2
votes
1answer
264 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
84 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
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
794 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
36 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
112 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
85 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 { ...
1
vote
0answers
16 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
121 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
59 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....
1
vote
2answers
384 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
24 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
435 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
65 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
149 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: ...