-
I am trying to create an EC2 instance with an EBS volume attached to the said instance. However, to create the EBS volume and attach it to the instance I need to use some terraform code. e.g. Layout tree is: dev In the ebs.tf file we can have
terragrunt.hcl
Is it possible to use the output of the instance and pass this parameter/object to the ebs.tf file so that the ebs volume gets attached to the instance on the fly? Another question is, is it possible for the *.tf files to use the variables defined in the .hcl files? e.g.
you can use the variable env as ${local.env} for your inputs |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Passing of variables to TF files can be done with
So |
Beta Was this translation helpful? Give feedback.
-
Hi, I can think of a scenario to use Example:
Execution:
https://github.com/denis256/terragrunt-tests/tree/master/variable-passing-module |
Beta Was this translation helpful? Give feedback.
-
OK so I have this almost working fully, well in fact it does work, I can grab the instance id and attach an ebs volume to this instance, but at the same time the ebs directory tries to create a new ec2 instance. This is not what I want as I have a ec2 directory looking after the entire ec2 instance creation. ├── ebs ebs.tf
terragrunt.hcl
terragrunt.hcl for the ec2 instance
Not sure why the ebs/terragrunt.hcl file wants to create a new instance when I can successfully get the instance id returned from the ec2-linux-ui dependency? If I can fix that, we are done. |
Beta Was this translation helpful? Give feedback.
OK so I have this almost working fully, well in fact it does work, I can grab the instance id and attach an ebs volume to this instance, but at the same time the ebs directory tries to create a new ec2 instance. This is not what I want as I have a ec2 directory looking after the entire ec2 instance creation.
├── ebs
│ ├── ebs.tf
│ └── terragrunt.hcl
└── ec2-instance
└── terragrunt.hcl
ebs.tf
terragr…