6 votes

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

Update: As of TF 0.13x, depends_on is supported to create dependencies between modules. Using depends_on should be preferable over using the method detailed below. The previous most popular answer is ...
MrPooh's user avatar
  • 61
6 votes
Accepted

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

The workaround is to pull the current state file, edit it and use it as a base line. For example: $ terraform state pull > terraform.tfstate $ vim terraform.tfstate # Carefully remove invalid ...
kenorb's user avatar
  • 7,631
6 votes
Accepted

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

The resource "azurerm_network_interface_backend_address_pool_association" "network_interface" block doesn't have the count argument set, so count.index is not meaningful in that block. Given the ...
Martin Atkins's user avatar
5 votes

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

These are hacks (understandably as you couldn't explicitly do this in Terraform < 0.13). Now however, with 0.13, we have depends_on for modules: https://github.com/hashicorp/terraform/blob/v0.13/...
Snowcrash's user avatar
  • 195
4 votes
Accepted

Module directory modules/queues.tf does not exist or cannot be read

A Terraform module is represented by a whole directory, not an individual file. If you create a directory ./modules/queues and move ./modules/queues.tf to ./modules/queues/queues.tf then you can call ...
Martin Atkins's user avatar
4 votes

What is the difference between modules and workspaces in Terraform

Terraform modules are a way to encapsulate reusable business logic in order to be DRY. For example, you might use a module to define a jenkins setup, then invoke that module every time you want a ...
Erik Osterman's user avatar
4 votes
Accepted

What is the difference between modules and workspaces in Terraform

I think a key difference between Terraform Modules and Workspaces is that modules can be inherited and used by other modules and configurations. Terraform Workspaces are intended to be a collection of ...
Preston Martin's user avatar
  • 3,153
4 votes

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

There is a hacky workaround for getting Terraform to do module dependencies. You can force the module to be aware of the Terraform calling it like this: # ROOT level main.tf # ------------------------...
Briansbum's user avatar
  • 1,112
3 votes

How to create dependency between modules in terraform

What you've described here is the recommended way to pass dependencies between modules, but it relies on features introduced in Terraform 0.12. You appear to be using Terraform 0.11, where ...
Martin Atkins's user avatar
3 votes

Terraform single-file modules

While it's best practice to use variables.tf and outputs.tf, both variables and outputs can be declared in any file - so in a way it just boils down to both personal preference along with any ...
Joan Serra's user avatar
2 votes

Terraform organising modules/code for multiple projects

Sorry for adding a direct answer, I cannot add comments still. So from what I have worked with and especially in companies that already had legacy infrastructure with legacy Terraform, that was not ...
Kristian Kanchev's user avatar
2 votes

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

Terraform is idempotent so will only change what needs to be changed. So after applying your existing plan, if you add more modules or resources and run another plan and apply, it will add the new ...
Alastair Montgomery's user avatar
1 vote

Include verbose output in terraform/terragrunt

You might be able to do something with the local-exec Provisioner to push the information out to an external script or file which you could monitor separately during the run. The issue you might ...
Alastair Montgomery's user avatar
1 vote
Accepted

conditionals in module providers meta-argument

The relationship between a resource and its provider configuration is an important part of building the dependency graph, and Terraform must build the dependency graph before it can evaluate any ...
Martin Atkins's user avatar
1 vote
Accepted

Terraform conditional block inside a map

This could be done with a dynamic block but its pretty complicated. This is how I would do it but there are other ways. variable "enable_vars" { type = bool default = false } ...
Levi's user avatar
  • 979
1 vote

How to fetch azure secret if exist in KV using terraform

This looks like a case for a conditional resource. First, look up the secrets with a data "azurerm_key_vault_secrets" block: data "azurerm_key_vault_secrets" "example" { ...
Bruce Becker's user avatar
  • 3,410
1 vote

TerraForm separate stages

I don't think there are any best practices because it would depend on both your company structure as well as how your developers manage their code in SCM (gitflow, trunk, etc). Lets start with the ...
Levi's user avatar
  • 979
1 vote
Accepted

Terraform get subnet id by it's CIDR block

It seems that you already know which CIDR ranges you wish to look up, and that you are trying to find the corresponding subnet id for each of them. You can achieve that by using the aws_subnet data ...
Martin Atkins's user avatar
1 vote

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

If I have read this correctly you are trying to target different clusters with your provider so you can then use a helm_release. You need to have distinct providers for each cluster and differentiate ...
krystan honour's user avatar
1 vote

How to use kubernetes_service data provider in Terraform?

The provider documentation you quoted here seems to have a mistake. It talks about using the two providers together in the same module but it seems like it really means in the same configuration. The ...
Martin Atkins's user avatar
1 vote
Accepted

Enable/disable resource in terraform using count

I believe you should be able to reference the namespace name like so: namespace_name = azurerm_eventhub_namespace.eventhub[0].name However, if the namespace_name field is a required parameter on ...
zm31's user avatar
  • 361
1 vote
Accepted

Why does my Terraform config require variables in multiple places?

Each module has its own set of input variables. The input variables for the root module are set when you run Terraform, e.g. on the command like with the -var option. The input variables for any ...
Martin Atkins's user avatar
1 vote

Unable to understand the logic behind this terraform function

It seems like the intent of this expression is to take the result of encoding that data structure which contains numbers and boolean values in quotes and produce a new version with those values ...
Martin Atkins's user avatar
1 vote

Terraform: Delay the MySQL Provider

I think you could achieve something similar by first running Terraform against your RDS resources, and then running Terraform again on all resources. On your first pass, you can use -target option to ...
Yekta Leblebici's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible