Questions tagged [terraform]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
2k views

Terraform | Upgrade to 0.12 error Reference to “count” in non-counted context

I'm trying to upgrade terraform from 0.11 to 0.12 but receiving error: Error: Reference to "count" in non-counted context on main.tf line 33, in data "aws_subnet" "public": 33: id = data....
0
votes
1answer
34 views

How to probe all running aws ec2 instances and their sec groups, etc to generate templates?

Typically I spin up all aws ec2 instances together with all its accompanying security groups, volumes, etc ... by executing a series of aws cli commands. However when I manually use the aws console ...
1
vote
0answers
194 views

Terraform destroys and creates new AWS resources [closed]

Terraform destroys and creates new AWS resources when I modify the modules with new resources. I tried with: lifecycle { prevent_destroy = true } Getting the below error : the plan would ...
1
vote
2answers
67 views

Which Users Should I Create With Terraform And Which With Ansible?

I am creating some Ubuntu VMs in Azure with Terraform. I am then configuring the VMs with ansible. When terraform creates the VM it creates an admin user resource "azurerm_virtual_machine" "main" { ...
0
votes
3answers
1k views

Service account permissions error when provisioning instance group from template

I'm trying to create a GCE Instance Group Manager using terraform resource "google_compute_region_instance_group_manager" "frontend_group_manager" { name = "frontend-igm" base_instance_name = "...
1
vote
1answer
1k views

How to forcibly remove the resource created by the broken module?

I've created few dns_cname_record resources, however Terraform DNS provider started to throw the errors like: Error: update server is not set I've created the bug report for it, as it prevents me ...
1
vote
1answer
5k views

Terraform | The “count” object can be used only in “resource” and “data” blocks,

I'm trying to upgrade out Terraform seeing as 0.12 (stable) came out recently. I've ran into some issues with a certain pair of resource blocks. I'm getting the below error message when trying to do ...
0
votes
1answer
302 views

Terraform: Route53, LB and CDN interdependencies

My team uses Terraform to deploy the necessary infrastructure. Currently, our stack is composed of: AutoScalingGroup fronted by a Load-Balancer, and a Route53 DNS record that points to this LB; We ...
2
votes
0answers
21 views

How to manage the database in an environment per branch, creating a new instance per branch is the best approach? [duplicate]

I'm trying to create an environment per branch using Git lab CI, until here we're good. But my concern right now is how to manage the Database? I thought of using RDS and terraform, but what I'm ...
0
votes
1answer
385 views

GCE metadata not defined on Travis CI

I have tried initializing terraform code in Travis CI but an error keeps coming up; Failed to load state: Failed to open state file at gs://{{project_id}}/terraform/state/default.tfstate: Get ...
1
vote
1answer
116 views

How to override default aws region credentials for Terraform?

I am using Terraform to create aws resources. I practiced with a single region and with my aws cli credentials being used. worked great! however when I tried to override the region in the Terraform ....
-1
votes
1answer
2k views

Terraform aws_ecr_repository resource always attempts to destroy

I have been banging my head against this seemingly simple issue for awhile now. I have some Terraform code which sets up an ECR repository, policy and lifecycle policy. provider "aws" { region = "...
0
votes
1answer
61 views

DevOps Newbie - How to automate windows infrastructure deployment?

DevOps newbie here, so bear with me. I have a project where infrastructure deployment and application deployment is done using powershell and it is tied to VMWare vCenter. For every client deployment,...
4
votes
2answers
2k views

Automate Helm's tiller installation with Terraform

I need to be able to generate disposable kubernetes environments using terraform. These environments should use helm for application deployment and ideally have tiller installed during the terraform ...
3
votes
3answers
4k views

Terraform - referencing existing security group

Is there a way I can associate existing security group to RDS that is going to be created or the only way is to recreate the security group so it can be added to the state file?
0
votes
1answer
238 views

Terraform: Provide credentials for docker hub registry

How would I provide docker hub credentials to a private image in the following example? data "docker_registry_image" "ubuntu" { name = "ubuntu:latest" } resource "docker_image" "ubuntu" { name ...
2
votes
1answer
3k views

Installing Helm charts using Terraform

I have been trying to install Helm charts using Terraform in a cluster which operates in GKE. My question is in two parts: Is it a good practice to use Terraform for installing Helm charts? I have ...
0
votes
1answer
468 views

Can Terraform S3 remote state be kept in a different AWS account?

I am currently using Terraform with S3 remote state. The IAM user that I'm using to run Terraform exists in the same AWS account as the S3 bucket holding the remote state files. This is all working ...
1
vote
1answer
608 views

How to pass HashiCorp Vault secrets(k/v passwords) to Terraform EC2 instance

How can we pass HashiCorp Vault secrets, k/v username/password and feed Terraform while its creating Ec2 instance. For example, i don't want to use in plain text variable "myvariable" { default = "...
2
votes
3answers
526 views

How to structure a IaC for production, and development?

We have a typical multi layered web application: a balancer, 2 web server 2 db server. I feel we strongly need to start using a kind of Infrastructure As Code in order to replicate easily ...
6
votes
3answers
19k views

How to make Terraform Modules wait for resources to be created in place of using computed values

Today I am working on building out several custom Terraform Modules. The issue that I am trying to figure out how to work around dependencies within modules. Until TF 0.12 is released we cannot ...
2
votes
1answer
324 views

Terraform - aws_security_group_rule doesn't support import

I'm having a strange problem when trying to import an aws_security_group_rule into terraform. I'm running the latest version of TF (0.11.11) For example: terraform import module.ec2....
1
vote
1answer
518 views

Terraform | AWS | vpc_id causing apply to fail

I am working on setting up a Cloud9 environment using Terraform, I ran into an issue when it comes to my Terraform apply and specifically: Error: Error applying plan: 1 error(s) occurred: * ...
2
votes
1answer
958 views

How to enable Google Maps and generate an API key using Terraform?

I've been trying to spin up a project from scratch over the Christmas break to automate the creation of my home network, one of those components is the Ubiquiti Controller which requires a Google Maps ...
1
vote
0answers
28 views

all volumes are geting deleted when one EC2 is being deleted via terraform [closed]

I am using this template to create aws resources. my count is 2, every thing is getting created as per plan,, i am attaching a 2nd ebs volume of 1 gb to both machines, which is also happening well, ...
3
votes
2answers
775 views

All volumes are deleted when EC2 intance is deleted via terraform

I am using a terraform template to create AWS resources. My count is 2, everything gets created as per plan, and, I am attaching a 2nd EBS volume of 1 GB to both machines, which is also happening well....
2
votes
1answer
175 views

How do I install Terraform libvrit_cloudinit?

I have searched all day trying to find a document on how to install the libvirt_cloudinit provider for Terraform. When I execute a terraform plan I encounter this error message: Error: ...
0
votes
1answer
41 views

Understanding contents and workwise of a Terraform plan

If you export a Terraform plan, it is a binary file. Now, calls to a cloud management interface are HTTP calls following corresponding REST APIs. Does this mean this internal Terraform format ...
1
vote
1answer
775 views

How can I use Docker Hub in Terraform?

The instructions in Terraform Docker Provider give the example: # Configure the Docker provider provider "docker" { host = "tcp://127.0.0.1:2376/" } # Create a container resource "docker_container"...
0
votes
1answer
81 views

How do I handle multiple AWS accounts in Terraform?

I've read up on Terraform and using AWS S3 and DynamoDB for sharing state and locking. My problem is that we have multiple AWS accounts, by which I mean multiple sign-in locations like: https://...
4
votes
1answer
79 views

Where do you start with hosting the infrastructure for your infrastructure?

So I'm trying to get started with the HashiCorp stack, but the question I keep asking myself, when looking at any of this DevOps infrastructure stuff, is what infrastructure should you be using to ...
2
votes
1answer
85 views

How do you handle the huge number of possible permutations of Dockerfiles / Teraform files?

We have adopted Docker and Terraform as the foundation forour devOps. We have a basic version of it up and running today. Dockerfiles live in each projects git repository and Terraform files are more ...
1
vote
2answers
3k views

Terraform plan -var-file=“myvars.vars” does not run [closed]

I try to lean terraform for usage with our AWS environment. I have created a .tf file and terraform init was successful. In the .tf file I have a number of variables that are populated via .var ...
2
votes
1answer
588 views

Jenkins Pipeline job - remember previous values

I have a Jenkins Pipeline which uses Terraform and create a compute environment in GCP. There are like 5 questions in the build i.e. 1) GCP Project Name 2) Number of RHEL Servers 3) RHEL Server names ...
2
votes
0answers
483 views

Provisioning times for Redis in cloud taking too long, how can we shorten it?

Provisioning a 1 GB Redis cache service on AWS takes around 8 minutes. Doing the same on Azure takes around 16 minutes. Ours Terraform scripts need the call back from the Redis systems. Why is this ...
-3
votes
1answer
117 views

Set user in aws

I have a lot of instance in aws.I have build through terraform. I have made scripts of making user(e.g. user1 rather than ec2-user).But i am facing one issue.when i check .ssh/authorized_key. I have ...
-3
votes
1answer
2k views

Make instance with newuser by terraform

I want to make new instance with "user1" rather than ec2-user(AWS) default.i want achieve this by terraform. Like in azure terraform it can be done by "os_profile{}", but how can i do in aws by ...
6
votes
2answers
661 views

Terraform AWS AZ error - manually specify AZ?

I'm fairly new to terraform and when creating AWS infrastructure I use the following to fetch the 'available' availability zones for my region (us-east-1) where I'm trying to create an EKS cluster. ...
2
votes
1answer
1k views

Terraform Issue - Can't find Data Source in Sub Module?

I'm fairly new to Terraform and have been following this example on creating an EKS cluster - https://github.com/terraform-providers/terraform-provider-aws/tree/master/examples/eks-getting-started ...
41
votes
4answers
44k views

Terraform: apply only one tf file

I have my security groups in a securitygroup.tf file. In the same dir there are plenty of other resource descriptions (rds, ec2 etc). Is there a way to perform a terraform apply --auto-approve only ...
2
votes
1answer
2k views

How to set an existing IAM role to a new instance while spinning in terraform?

I am trying to attach an existing role created in AWS, but I am not able to add it in Terraform Code. I tried to add the role in instance profile but it didn't work either for me. Is there any direct ...
1
vote
1answer
167 views

Deploying a SaaS solution which is custom for every customer

So we have 5 repositories (Individual web services ex. CMS/E-commerce and internal APIs) which are currently deployed as Docker containers. What we plan to do is to use these services and make a ...
1
vote
1answer
1k views

Terraform: ignore_changes conditionally? (temporary EC2 instance public IP address)

I've got a couple of EC2 instances managed by Terraform, with public IP addresses in a VPC. With each Terraform run, I'm updating DNS records based on those public IPs. I don't need these instances ...
1
vote
0answers
80 views

Creating a buildspec inside the buildproject itself [closed]

I have used cloudformation using yaml to build a pipeline AWS Codepipeline and there was a clear option to update the build commands using the script, How can I include the build commands inside the ...
7
votes
2answers
892 views

How to add shards to a Redis cluster managed by Terraform without loosing all state?

I have set up a Redis cluster with Terraform. The setup looks like this: resource "aws_elasticache_replication_group" "instance" { replication_group_id = "test" node_type = "...
3
votes
4answers
2k views

How can I get terraforms extern to execute `ssh-keygen -y -f ~/.ssh/id_rsa`?

I seem to be confused about how external works. I tried: data "external" "local_key" { program = [ "ssh-keygen", "-y", "-f ~/.ssh/id_rsa" ] } This gives me: failed to execute "ssh-keygen":...
4
votes
1answer
867 views

Create multiple EC2 instances using python script (in loop iteration)

I Have JSON file in which email address and count of instances are specified.I'm using python script to iterate through that file and get username/count number (count number will be used as number of ...
5
votes
1answer
517 views

Terraform: Delay the MySQL Provider

I have a Terraform project which uses the MySQL provider. Because of the way Terraform works, the MySQL provider will fail to load correctly because the AWS_RDS instance doesn't exist. Is there a ...
6
votes
6answers
710 views

In the HashiCorp stack, where's the appropriate place to add users?

I'm in the process of building some custom Linux images using HashiCorp's Packer, which will later be deployed to Azure using HashiCorp's Terraform. The VMs created from these images will need to have ...
2
votes
2answers
297 views

Can jenkins control baremetal with ipmi

I have a setup with a bunch of blades that pxe boot into coreos using terraform/matchbox setup. I currently control them all manually using ipmitool from my desktop. Is there a way to let jenkins ...