Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

🚗 You set the rental price
🔐 Secure bookings with verified renters
📍 Track your vehicle with GPS integration
💰 Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

Terraform source for Modules from Git: All Patterns & Examples

Here’s a comprehensive tutorial on all valid Terraform module "source" Git URL patterns, with clear examples (no Drivemode references), so you can master using modules from GitHub, GitLab, Bitbucket, and private repos.


✅ Terraform source for Modules from Git: All Patterns & Examples

Terraform supports loading modules from Git repositories using either HTTPS, SSH, or GitHub short syntax. Below are all common patterns with examples.


🔹 1. GitHub (HTTPS)

Use this when you don’t want SSH keys or are using public repos.

module "vpc" {
  source = "git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git"
}
Code language: JavaScript (javascript)

✅ With Subdirectory

module "s3" {
  source = "git::https://github.com/your-org/terraform-modules.git//modules/s3_bucket"
}
Code language: JavaScript (javascript)

✅ With Tag / Branch

source = "git::https://github.com/your-org/terraform-modules.git//modules/s3_bucket?ref=v1.2.0"
source = "git::https://github.com/your-org/terraform-modules.git//modules/s3_bucket?ref=main"
Code language: JavaScript (javascript)

🔹 2. GitHub (SSH)

Use SSH if you’re pulling private modules using a deploy key or SSH agent.

module "eks" {
  source = "git::ssh://git@github.com/your-org/terraform-modules.git//modules/eks_cluster?ref=main"
}
Code language: JavaScript (javascript)

✅ Use git::ssh:// for SSH – don’t use raw git@github.com.


🔹 3. GitHub (Short Syntax – Only for Public Modules)

module "vpc" {
  source = "github.com/terraform-aws-modules/terraform-aws-vpc"
}
Code language: JavaScript (javascript)

⚠️ This works only for the root of the repo (no subdirectories, no tags).


🔹 4. GitLab (HTTPS)

module "firewall" {
  source = "git::https://gitlab.com/your-org/infra-modules.git//firewall?ref=main"
}
Code language: JavaScript (javascript)

🔹 5. Bitbucket (HTTPS)

module "app" {
  source = "git::https://bitbucket.org/your-team/terraform-modules.git//modules/app?ref=release-1.0"
}
Code language: JavaScript (javascript)

🔹 6. Private Git Repos (with SSH)

module "db" {
  source = "git::ssh://git@bitbucket.org/your-org/terraform-db-modules.git//rds?ref=main"
}
Code language: JavaScript (javascript)
  • Make sure your runner (Terraform Cloud or CI) has access via SSH key.
  • Can also use .netrc or GIT_ASKPASS for HTTPS auth in private repos.

📦 Structure of a Terraform Git Source URL

git::<protocol>://<host>/<repo>.git//<subdir>?ref=<branch|tag|commit>
Code language: HTML, XML (xml)
PartExample
git:: prefixtells Terraform to treat it as a Git source
https:// or ssh://Git protocol
//modules/xpoints to subdirectory inside the repo
?ref=tag, branch, or commit hash

✅ Pro Tips

TipReason
Always pin a tag using ?ref=...Prevents breaking changes
Use double slashes // before module subdirRequired for subdirectory paths
Prefer HTTPS for public or Terraform CloudEasier integration
Use SSH only if you’ve configured keys properlyAvoids access errors

🚀 Real-World Example

Let’s say you have this repo:

https://github.com/acme-corp/terraform-infra-modules
Code language: JavaScript (javascript)

With a folder structure like:

terraform-infra-modules/
├── vpc/
├── eks/
└── s3/

You can use:

module "vpc" {
  source = "git::https://github.com/acme-corp/terraform-infra-modules.git//vpc?ref=v1.0.0"
}

module "eks" {
  source = "git::ssh://git@github.com/acme-corp/terraform-infra-modules.git//eks?ref=main"
}
Code language: JavaScript (javascript)

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x