Questions tagged [terraform]

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

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

Provision and configure Azure VM in private subnet (file, remote-exec, cloud-init, etc.)

(Originally posted to discuss.hashicorp.com) I’m setting up a basic multi-tier infrastructure composed of two Azure VMs: Web server (VM1) with public IP and private IP (subnet1) Data server (VM2) in ...
0
votes
0answers
16 views

Help on Setting up k3s

I wanted to learn Kubernetes so I read through a lot of articles about it and I really want to try using it. So I signed up for Azure trial and learnt few things about how to do stuffs with Azure and ...
-1
votes
1answer
13 views

Can I get terraform Graph to act on only my changes not the whole statefile?

A few months ago I ran a plan for my comment with terraform graph to show my changes I was adding 18 resources to my component and wanted a diagram I could check to see all the resources with there ...
1
vote
1answer
31 views

Populate Database

I am using Terraform Cloud to build the infrastructure. One of the resources is a postgresql database. What is the best way to populate the database by creating tables, multiple schema etc after the ...
0
votes
0answers
16 views

How to use terraform-docs with no modules (only root module)?

I have been trying to use terraform-docs with a Terraform sample infrastructure which is not organized into modules, so it only has the root module (as we read in modules docs). I started by ...
3
votes
1answer
28 views

Dedicated/Separate Git Repo as Terraform Remote Backend

I see that there are multiple options for Backends, however git isn’t one of them. I believe git can be used as a backend for tfstate, in the below steps: Create a dedicated git repo Commit the ...
1
vote
1answer
21 views

Terraform: Sanitize a map that may be a map of strings or map of maps or combo of both

I want to take a map such as this that is passed in as a variable cidrs = { A = [1.1.1.1] B = [2.2.2.2, 3.3.3.3] Group1 = { C = [4.4.4.4] D = [5.5.5.5] } } and then within the locals ...
0
votes
0answers
13 views

Terraform resource state depending on another resource's creation?

I'm trying to create a VPC connector using Terraform for Google Cloud. Querying the state of the connector requires the VPC Admin API resource to be enabled: resource "google_project_service"...
0
votes
2answers
57 views

How can I list all environment variables configured in Terraform?

I configured AWS provider in Terraform by providing an access key and secret as environment variables according to the documentation: $ export AWS_ACCESS_KEY_ID="anaccesskey" $ export ...
0
votes
1answer
23 views

Find relevant domain/hosted zone under which to host subdomain

Context In Terraform, to create a new domain record, I first need to find the zone under which it should be hosted. E.g. If I want to create a DNS record for mysite.example.com, I'd get the zone ...
1
vote
3answers
61 views

How to produce a map from the cartesian product of two lists to use with for_each on a resource with Terraform

I need to create a datadog synthetics monitors with the resource datadog_synthetics_test I need to monitor multiples cluster, with multiple point of view : # Clusters variable "...
1
vote
0answers
28 views

Include verbose output in terraform/terragrunt

Is there any way to include verbose / debugging output in Terraform / Terragrunt? I'm new to the language, and often struggle with knowing exactly what's going on. It would be helpful for me to be ...
0
votes
0answers
24 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
35 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
46 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
27 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
14 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
46 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
99 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
97 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
30 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
141 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 = [ ...
2
votes
1answer
41 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....
1
vote
1answer
91 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
774 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 "...
2
votes
3answers
620 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
335 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: ...
1
vote
1answer
28 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
40 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
335 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
34 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
21 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
68 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
402 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
88 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
142 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....
1
vote
1answer
109 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
31 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
22 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
234 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
36 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
117 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
94 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
29 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
60 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
365 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
360 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
118 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
14 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
1k 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 ...