HPE Morpheus Enterprise
1831345 Members
3036 Online
110024 Solutions
New Discussion

Load terraform modules from local in blueprints

 
Not applicable

Load terraform modules from local in blueprints

We have a terraform module to create a VPC inside git repository, we need to load this module for all other terraform code in the same git repository. Like below,

While creating blueprints for terraform, the ‘working path’ field has an option to pass the directory path to access the terraform code, say ‘EC2’ from the image shown above, doing this loads only the code related to EC2, the ‘VPC’ code inside modules folder code cannot be loaded(Note : Path of the VPC module is give in EC2 terraform code as ‘source=…/modules/vpc’)

Is there any possible option to pass multiple working paths or any other way to load this ‘VPC’ module during terraform init?

3 REPLIES 3
Not applicable

Re: Load terraform modules from local in blueprints

Tried that but the problem is passing the working path as ‘AWS/EC2’ as below,

This loads the files only related to EC2 folder
main.tf
outputs.tf
variables.tf
The tf files inside module folder also need to be loaded like,
main.tf
outputs.tf
variables.tf
modules/vpc/main.tf
modules/vpc/outputs.tf
modules/vpc/variables.tf

Passing as source=…/modules/vpc will not load modules.
Is there a way to add this module folder in the working path?

rbmorph
HPE Pro

Re: Load terraform modules from local in blueprints

This is what I see with a setup similar to what you provided. My module directory is one up from my working directory. Can you provide your TF code somewhere with the full structure that I can test against? You wont see all the files but you should see the module reference.

9cf40269bd6924e9a82a770aa7b2903bb26fa3c0.png

My module reference in my main.tf in the working directory looks like this.

59a54f8b94614651f936f4b0a5f2f991a4572d06.png

rbmorph
HPE Pro

Re: Load terraform modules from local in blueprints

based on the tree you provided it looks like your module directory is one directory up from your working path assuming EC2 is the working directory. Can you try “source=../modules/vpc” This would specify one directory up from TF.