CareerByteCode’s Substack

CareerByteCode’s Substack

Share this post

CareerByteCode’s Substack
CareerByteCode’s Substack
Terraform init not working when specifying modules
Tech Queries

Terraform init not working when specifying modules

Terraform - troubleshooting

CareerByteCode's avatar
CareerByteCode
Aug 03, 2024
∙ Paid

Share this post

CareerByteCode’s Substack
CareerByteCode’s Substack
Terraform init not working when specifying modules
1
Share

I am new to terraform and trying to fix a small issue which I am facing when testing modules.

Below is the folder structure I have in my local computer.

enter image description here

I have below code at storage folder level

#-------storage/main.tf

provider "aws" {
  region = "us-east-1"
}

resource "aws_s3_bucket" "my-first-terraform-bucket" {
    bucket = "first-terraform-bucket"
    acl = "private"
    force_destroy = true
}

And below snippet from main_code level referencing storage module

#-------main_code/main.tf

module "storage" {
    source = "../storage"
}

When I am issuing terraform init / plan / apply from storage folder it works absolutely fine and terraform creates the s3 bucket.

But when I am trying the same from main_code folder I am getting the below error -

main_code@DFW11-8041WL3: terraform init
Initializing modules...
- module.storage
Error downloading modules: Error loading modules: module storage: No Terraform configuration files found in directory: .terraform/modules/0d1a7f4efdea90caaf99886fa2f65e95

I have read many issue boards on stack overflow and other github issue forums but did not help resolving this. Not sure what I am missing!

Troubleshooting and Answer for the above issue :

Keep reading with a 7-day free trial

Subscribe to CareerByteCode’s Substack to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 CareerByteCode
Publisher Privacy
Substack
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share