Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

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)

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Top 10 Subscription Management Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction Subscription management software is designed to streamline and optimize the process of managing recurring billing, customer subscriptions, and related business operations. In 2026, with the rapid…

Read More

Top 10 AI Data Integration Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI data integration tools are pivotal for businesses navigating the complexities of modern data ecosystems. These tools combine artificial intelligence with data integration processes…

Read More

Top 10 Fleet Management Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, the logistics and transportation industries are evolving rapidly, and managing a fleet of vehicles has never been more complex. Fleet management software has become…

Read More

Top 10 AI Academic Plagiarism Checkers Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI academic plagiarism checkers have become indispensable tools for students, educators, researchers, and institutions striving to uphold academic integrity. With the rise of AI-generated…

Read More

Top 10 Travel Management Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, travel management software (TMS) has become a crucial tool for businesses, travel agencies, and frequent travelers. These tools automate the booking, tracking, and management…

Read More

Top 10 No-Code Platforms Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, no-code platforms have become essential for businesses and individuals looking to build powerful applications, websites, and automations without the need for programming knowledge. These…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x