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

Terraform cannot destroy with EBS volume attached

to detach from Instance (): unexpected state 'busy', wanted target 'detached'. last error: %!s(<nil>) I get the above error when I try to run terraform destroy. I think the ebs volume must be ...
0
votes
0answers
10 views

Restricting one module for one tf file

So I have file called main.tf in which I am calling the existing module for iam_role, but in same main.tf I have called one more module for service_role but I want to restrict that service_role module ...
1
vote
1answer
23 views

Why is Terraform not picking up locals.tf?

Here are my files so far. main.tf data "my_vars" "vars" { certificate_arn = local.certificate_arn } variables.tf variable "certificate_arn" { description = "...
0
votes
1answer
26 views

Are multiline lists valid in Terraform?

I currently have the following. module "module-name" { source = "./directory" environment = var.environment team_names ...
0
votes
0answers
3 views

How to handle configuration dependency which has links to resources beyound subscription?

I have a subscription in Azure that is a part of bigger configuration, which I don't have access to. (I know they use Ansible). I am given a Private DNS Zone which has been originally created by ...
0
votes
0answers
24 views

Error 403 while connect azure with terraform

I am trying to create VM on azure using terraform using article while getting below error : root@ip:~/terraform-azure-windows-vm-scale-set# terraform plan ╷ │ Warning: Value for undeclared variable │ │...
2
votes
0answers
19 views

Is it possible to loop through ec2 resources created with a count variable, while in the same module?

I have an ec2 module, which determines the number of instances via a count variable, like so: resource "aws_instance" "this" { count = var.instance_count I would like to ...
3
votes
1answer
51 views

Gitlab CI: change pipeline definition dynamically

I need to pass info from stage A to stage B so I can change stage B dynamically. Details: I have a stage (A) where I validate a terraform plan and check if it's going to destroy resources. I have ...
0
votes
1answer
50 views

Making aws_lb_listener default_action dynamic

I use Terraform a mostly uniform group of servers - EC2, S3 etc. This works reasonably well, except we need to have rather different actions for the load balancers depending on the specific group, and ...
2
votes
2answers
40 views

Get a list of remote VPCs on AWS using Terraform?

I'd like to get a list of all remote VPCs from AWS with terraform. I've read the documentation and found two data sources: AWS_DEFAULT_VPC AWS_VPC The first one will give you the default VPC and the ...
3
votes
2answers
99 views

Get private key from terraform state?

I used the terraform resource tls_private_key to generate a key and push that into AWS, but it didn't give me the private key to use to access the related resources. How can I recover that key?
1
vote
2answers
46 views

Dynamic environments per client, which is the best approach, if any?

I don't know how to explain this problem better, but I'll try to explain it clearly: Where I work our customers are companies, with lots of users We offer a SaaS solution for them to manage stuff For ...
0
votes
1answer
98 views

Terraform organising modules/code for multiple projects

I'm fairly new to TF and wonder how people are structuring Terraform for bigger infrastructure. We are moving our infrastructure to Terraform bit by bit. I'm curious how people are approaching that. ...
0
votes
0answers
15 views

How to limit access to internal AWS instances by other services and developers?

I have a dozen instances and lambdas, most of which are not publicly accessible. There are several dozen developers. Everything is currently managed by terraform. I would like to restrict access to ...
1
vote
1answer
36 views

Root ssh key for ansible control node

Scenario: Deploy 30 VMs using terraform and then run ansible - how many ssh keys do you generate? Virtual machine definition in terraform requires administrator ssh key or password provided. Do you ...
0
votes
1answer
28 views

Terraform import and using ip address as attribute name

I am building terrform.tfstate files from Terraform managed Fortigate devices. After producing output JSON files using Terraform output and a custom script to produce tf.address.tf.json, I wish to ...
3
votes
1answer
150 views

Terraform apply output only

I'm trying to apply only the output variable definition. Here is the "output" I want to apply. output "environment_information" { value = { foo = "value1" ...
1
vote
0answers
19 views

Native Terraform AWS Auto-Scaling Group Management with health Checks

I have been using CloudFormation for the past 3 years to manage AWS infrastructure which consists of multiple auto-scaling groups with immutable AMIs (amongst other things). I am trying to rewrite ...
1
vote
1answer
57 views

Using counted data source in non-counted provider block in Terraform

I'm new to Terraform, I need suggestion about handling one case where I need to use data from counted data-source to un-counted provider. I need to fetch the gke-cluster context and pass it to ...
1
vote
3answers
57 views

Does it make sense to create CloudFormation Stack using Terraform?

I am not very familiar with AWS, but I know the basics. So please forgive me for any newbie mistakes in the question. I am trying to integrate our AWS accounts with a vendor app. The vendor has ...
0
votes
1answer
21 views

Resources don't seem to show up in Terraform state after import

I'm in the middle of importing a bunch of AWS resources into Terraform by doing the following: put a stub resource into a .tf file terraform import the resource (using the same address) copy the ...
1
vote
1answer
142 views

How to use kubernetes_service data provider in Terraform?

I have simple workflow. Create a cluster, install ingress with helm and once it's ready, get load balancer's IP address to update CF dns records. It's all in one script. After creating nginx-ingress ...
4
votes
1answer
138 views

Terraform: how do you inspect sensitive data?

In a resource of type aws_ecs_task_definition my plan has an line that looks like this: ~ container_definitions = (sensitive) # forces replacement Now in principle this could be doing anything - ...
0
votes
3answers
197 views

Do I have to include gitlab variables in my terraform code in order for my credentials to be recognized?

I am trying to set up a pipeline, which is supposed to deploy terraform code into an aws account. The code works fine locally, and I have setup and imported the state bucket and dynamodb table which ...
1
vote
1answer
61 views

How CircleCI, Terraform and AWS should interact in CI/CD Pipeline

I'm new to devops and I'm have a hard time finding resources to help me with this question. My Goal is to have an automated CI/CD pipeline to launch my project. Basically I have a GitHub repo with a ...
0
votes
1answer
38 views

Terrafrom to declare both infra and application deployment in one state

Are there any advantages of maintaining both infrastructure (Infra-as-code) and application/service (helm chart deployment using helm_release provider of terraform ) under one state file? I don't like ...
0
votes
2answers
42 views

How to get code onto aws ec2 instance using terraform and gitlabs

I've just started learning Terraform (utilizing the AWS provider) and I have managed to replicate our infrastructure which includes quite a few amazon web services. I can successfully deploy it and ...
1
vote
0answers
17 views

How Do I Get A Summary of Task Times With Terraform?

If I run ansible with profile_tasks I get a nice table at the end that shows me how long each task took. How can I get a similar summary at the end of running terraform apply?
3
votes
2answers
3k views

How do I use the remote-exec provisioner with Terraform?

I am using Terraform 0.14 and AWS. I am trying to write a .tf file that will invoke a remote-exec command via Terraform's provisioner. This code does not work: resource "aws_instance" "...
1
vote
1answer
177 views

Terragrunt Linter

I'm having troubles using HCL files at VSCode. When I open the HCL file the indentations are messy. So I fix it and close the file, when I open again...messy again... Someone know a add-ons to works ...
1
vote
1answer
294 views

How do I enable Google App Engine API with Terraform?

I'm attempting to enable the AppEngine service via Terraform but I'm getting an error: Error: Error creating App Engine application: googleapi: Error 403: App Engine Admin API has not been used in ...
0
votes
1answer
498 views

Enable/disable resource in terraform using count

I added a piece of code to support enable/disable to the feature - I used the count. Now I have the following problem: ERROR: on modules/eventhub/main.tf line 110, in resource "azurerm_eventhub&...
1
vote
0answers
22 views

How to test pipeline changes in Azure?

I currently have a pipeline in Azure which consists of a bunch of YAML which eventually calls some terraform script to handle the deployment side. What is the best way to handle dev testing of changes ...
1
vote
1answer
297 views

What does "eksctl create iamserviceaccount" do under the hood on an EKS cluster?

AWS supports IAM Roles for Service Accounts (IRSA) that allows cluster operators to map AWS IAM Roles to Kubernetes Service Accounts. To do so, one has to create an iamserviceaccount in an EKS cluster:...
1
vote
1answer
178 views

Is it possible to have an aws EKS infrastructure as code?

Is it possible to declare "a complete production level EKS with other aws services" using terraform? I know that terraform has an eks module and an aws provider. But I'm not sure if one can ...
1
vote
1answer
59 views

How can I add another module to my existing Terraform deployment plan?

I have deployed a project within Terraform. I need to add a 4th application module to my existing plan. How do I update my plan to include this 4th module and deploy the missing module without ...
4
votes
2answers
70 views

Are there automated quality checking tools for Ops code

In the dev world, we have several tools available to us for automated quality checks. We have unit tests that run on each build, Sonar to check for code quality, metrics being sent to Grafana and ...
1
vote
1answer
66 views

IaC Deployment in Azure with Terraform + Chef vs. Puppet vs. Ansible for Data Engineers

I am an Azure Data Engineer and try to leverage the IaC benefits in this area of Azure Data Factory, Azure Databricks, Azure SQL & Synapse, Azure Power BI, Azure IoT. After some research I figured ...
4
votes
1answer
638 views

Terraform variable Validation

is it possible to use validation of a variable type equals list(string)? My example: main.tf name = "tf-prd-sg-foo" image_id = "ami-00e788542ee66c64f" ...
1
vote
1answer
580 views

Terraform - gitlab provider does not start

I am using terraform docker image hashicorp/terraform:latest and I define the provider in main.tf as follows: terraform { required_providers { gitlab = { source = "gitlabhq/gitlab&...
1
vote
0answers
18 views

Define a repo logo via terraform github_repository

Is there a way to give my terraformed github_repository a custom logo? The doc doesn't have a field for it, but is there an undocumented feature? Branding is important!
1
vote
1answer
148 views

Using a combination of Terraform and Ansible to create dynamic AWS EC2 infrastructure

The company I work for wants to prevent provider lock-in adn therefore told us to use Terraform+Ansible instead of Cloudformation. We already decided to use terragrunt as an addon. While the ...
2
votes
1answer
629 views

Terraform ignore_changes block on JSON-encoded attribute

I'm currently trying to get CloudWatch logging and DMS configuration working smoothly in my module by ignoring certain attributes on replication_task_settings. Right now, I have a DMS replication task ...
1
vote
1answer
13 views

Mass remove/add to multiple security groups cross region

Would it be possible to create a script or use something like terraform to mass remove/add security group entries across several regions under the one account based on the security group name? ...
4
votes
4answers
1k views

Is there a way to lint Terraform?

I'm hoping there is something to pick up when I have misspelled variables and comments to save me some time when I'm checking my code and reduce the potential for any errors. I normally use IntelliJ ...
1
vote
1answer
190 views

Terraform deletes AWS lambda layers instead of keeping the older versions

I am using terraform version 12.26 for AWS deployment. Whenever I try updating a lambda layer, the lambda layer version is incremented, but the older layer is deleted. Even though my current version ...
0
votes
1answer
182 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}" ...
1
vote
1answer
381 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
1answer
882 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
31 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....