Dear all,
I’m new with Terraform and therefore took time to go through the . documentation and several threads but unfortunately I’m still missing a piece about modules’ structure and configuration.
I’m currently starting a build several configurations and try to structure them the best way possible.
Basically I’m using Terraform for both AWS and OCI. To do so I created a folder dedicated to Terraform with 2 subfolders (AWS and OCI). I will put all modules for AWS in the first one and the modules for OCI in the second one.
Beside, I’m trying to follow the principle of having a main.tf as well as a tfvars file for the variables and an outputs.tf.
As I’m going to have different kind of configuration such as Reporting, Deploy workshop, Deploy PaaS my idea is to have a structure like the following:
Terraform
|
|----> AWS
|----> OCI
|-----> Reporting
|-----> Deploy_workshop
|-----> main.tf
|-----> outputs.tf
|-----> variables.tfvars
The first question is does it make sense the organise things like that?
While setting this up, I went in the documentation about modules and calling child modules as there will be some common commands that could be mutualised between the projects.
Here the first challenge I do not get working is to configure the provider only once and not in each “project”.
I have the following for the provider:
provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
region = var.region
}
and stored it directly under teh OCI folder.
Now in the main.tf of the reporting “project” for instance, I tried to call the provider as a module:
module "oci" {
source = ".."
}
I tried several values for the source but I always get an error saying unknown module “oci”.
Any idea how I could configure / define my provider only once and then call it in my different projects??
Many thanks for your support!
David