Questions tagged [terraform]

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

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

Terraform foreach multiple map variables

I need to do the following in Terraform but can't work out how Here is what I have local { app_config = { test-web = { name = "test-web-${local.environment}" ...
0
votes
1answer
16 views

Can you inherit a template_cloudinit_config in another template_cloudinit_config object in Terraform?

I recently discovered template_cloudinit_config within Terraform, and I'm hoping I can utilize it to specify something like the code below. Basically my goal is to declare a core ...
0
votes
0answers
6 views

Need advice to setting up a Jenkins blue/green infrastructure, from a high level?

I'm trying to use Terraform to setup a blue/green Jenkins deployment. The idea is to setup a green infrastructure for testing, and when that is good, promote it as the blue node to be used for ...
0
votes
0answers
31 views

Golang + Terraform in Gitlab CI

I have an application made of two compiled Go programs and a Terraformed test stack. There will be more functions and resources in the coming weeks. Maybe other technologies that will need other ...
0
votes
1answer
25 views

Terraform Dynamic Block with list intro them

I'm creating a AWS Cloudfront module and some troubles are happening because have some Cloudfront parameters that are "dynamics/optional" too. When I'm trying run the $ terraform validate ...
0
votes
1answer
15 views

Create dynamic resources using 'for_each' or 'for'

I want to create multiple resources using this: resource "group" "list" { g_name = group_name p_name = project_name } The input local variable is nested: > local....
0
votes
0answers
9 views

Terraform | depends_on causes sequence problems for incremental updates

Summary: depends_on of Terraform works fine, BUT when I have an incremental update with new resources going in-between then it causes the new resources to run in parallel (which will NOT if I run it ...
0
votes
0answers
10 views

Private EKS behind corporate Proxy - with Terraform

I have built a private EKS cluster, im now going through the motions of trying to attach a Managed Node group to the cluster using Terraform. Looking through lots of resource the Node group required ...
0
votes
1answer
18 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
19 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
vote
2answers
42 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
32 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
45 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
28 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
15 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
69 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
26 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
109 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
56 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
33 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
40 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
1answer
93 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
31 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
17 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
50 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
175 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
103 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
212 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
54 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
148 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/...
2
votes
2answers
2k 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
1k 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 ...
3
votes
2answers
934 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
49 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
694 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
56 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
22 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
202 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
653 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
131 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
244 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
162 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
34 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
23 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
301 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
40 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
232 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
134 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 ...