Terraform init throws error : Error: Failed to download module

Hello,

I am facing issue with respect to running terraform init in Bitbucket Pipelines, wheras these code works on local machine.
Terraform init does not run successfully on Bitbucket pipelines during initial first run.

  • terraform init
    Initializing modules…
  • aws-services in …/…/modules/aws-services
  • cluster in …/…/modules/cluster
    Downloading terraform-aws-modules/eks/aws 12.2.0 for cluster.eks…
    Downloading terraform-aws-modules/vpc/aws 3.0.0 for cluster.vpc…
  • elasticsearch in …/…/modules/elasticsearch
  • ingress in …/…/modules/ingress
  • ingress.letsencrypt_issuers in …/…/modules/k8s_manifest
  • ingress.wildcard-domain-certificate in …/…/modules/wildcard-certificate
  • ingress.wildcard-domain-certificate.k8s_manifest_domain_wildcard in …/…/modules/k8s_manifest
  • ingress.wildcard-subdomain-certificate in …/…/modules/wildcard-certificate
  • ingress.wildcard-subdomain-certificate.k8s_manifest_domain_wildcard in …/…/modules/k8s_manifest
  • k8s_cluster_config in …/…/modules/k8s_cluster_config
  • k8s_cluster_config.k8s_pod_network_policies in …/…/modules/k8s_manifest
  • k8s_cluster_config.k8s_pod_security_policy in …/…/modules/k8s_manifest
  • kubed in …/…/modules/kubed
  • monitoring in …/…/modules/monitoring
    Error: Failed to download module
    Could not download module “eks” (…/…/modules/cluster/eks.tf:1) source code
    from
    “git::GitHub - terraform-aws-modules/terraform-aws-eks at v12.2.0”:
    error downloading
    GitHub - terraform-aws-modules/terraform-aws-eks at v12.2.0’: git
    must be available and on the PATH.
    Error: Failed to download module
    Could not download module “vpc” (…/…/modules/cluster/vpc.tf:1) source code
    from
    “git::GitHub - terraform-aws-modules/terraform-aws-vpc at v3.0.0”:
    error downloading
    GitHub - terraform-aws-modules/terraform-aws-vpc at v3.0.0’: git
    must be available and on the PATH.
    Error: Failed to download module
    Could not download module “eks” (…/…/modules/cluster/eks.tf:1) source code
    from
    “git::GitHub - terraform-aws-modules/terraform-aws-eks at v12.2.0”:
    error downloading
    GitHub - terraform-aws-modules/terraform-aws-eks at v12.2.0’: git
    must be available and on the PATH.

I saw these bug reported multiple times and solution provided
https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/versions.tf
but even after the changes suggested not able to run it via CI server : Bitbucket

local configurations

terraform version
Terraform v0.13.2

* provider registry.terraform.io/carlpett/sops v0.6.2
* provider registry.terraform.io/hashicorp/aws v3.37.0
* provider registry.terraform.io/hashicorp/external v2.1.0
* provider registry.terraform.io/hashicorp/helm v2.1.2
* provider registry.terraform.io/hashicorp/kubernetes v2.1.0
* provider registry.terraform.io/hashicorp/local v2.1.0
* provider registry.terraform.io/hashicorp/null v3.1.0
* provider registry.terraform.io/hashicorp/random v3.1.0
* provider registry.terraform.io/hashicorp/template v2.2.0
* provider registry.terraform.io/hashicorp/tls v3.1.0

Hi @Snehil03,

The “git must be available and on the PATH” error indicates that you do not have git installed in the PATH on the system you are using. You will need git to be installed if you want to use modules that are fetched via git.

1 Like

Hi @jbardin Indeed git was missing added it , made few more changes now this thing fly,
thanks !

Thanks, this answer helped me resolve my issue :grinning:

@jbardin Thanks!!. It really help’s for beginner’s