Referring to resources named with variables in Terraform

I was fundamentally misunderstanding how modules worked. Terraform does not support interpolation in resource names (see the relevant issues), but that doesn’t matter in my case, because the resources of each instance of a module are in the instance’s namespace. I was worried about resource names colliding, but the module system already handles that.

How to apply SQL Scripts on RDS with Terraform

Like this solution, You can also avoid instance setup time/cost by using your own machine with local-exec IF your RDS database is publicly available and you have setup ingress to allow your machine to connect. Then, with credentials stored securely in your environment, you would just do something like: resource “null_resource” “db_setup” { # runs … Read more

How to give a .tf file as input in Terraform Apply command?

You can’t selectively apply one file and then the other. Two ways of (maybe) achieving what you’re going for: Use the -target flag to target resource(s) in one file and then the other. Put each file (or more broadly, group of resources, which might be multiple files) in separate “modules” (folders). You can then apply … Read more

Terraform: Output a field from a module

So first, you need to set the output in the module asg: $ cat asg/output.tf output “blah-es-asg” { value = “${aws_autoscaling_group.blah-asg.arn}” } Then you call the module with source = “asg”: module “blah-asg” { source = “asg” asg_max_size = 1 asg_min_size = “${var.min_blah}” … } You can output it in current code with this format … Read more