Hi Chamila -
Thanks for your email.
The use cases are around creating resource IDs (hopefully this is right term) that have dependencies/ interconnections on other resources.
The example I showed was a Kinesis Firehose stream that needs other resources such as the s3 bucket.
So I could give the stream ID a value from the var file say "stream-1" then create the s3 bucket as $
var.stream-1.name."ec2".
Thus: resource would be "aws_kinesis_firehose_delivery_stream" "${var.stream-1}_stream" instead of "extended_s3_stream"
and its related bucket: resource "aws_s3_bucket" "${var.stream-1}_s3"
That way I could change the stream name (the primary resource) at will and confirm anything connected to this resource will get consistent name and related other attribute values - such as: name = "terraform-kinesis-firehose-extended-s3-test-stream"
It would be a big value in being able to define multiple different VPCs for example. within an environ such as DEV/ PROD - but I believe its value is more for resources such as data related environs, where multiple types of that resource and dependencies can coexist.
From a doc standpoint it would also allow us to look at a var file and see what is defined at a glance.
I guess we can already do is define them as variables in a module as in:
variable "ENV" {}
variable "AWS_REGION" {}
module "main-vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "vpc-${var.ENV}"
...
}
So I am not sure why I cannot just create such in a file use a variable. I eventually plan to migrate to modules anyway - so i should be ok?
Hope my questions (and answers) are not too confusing.
Please consider that I am a newbie in this coming from a DBMS/ Python background.
Thank you.
Mono