Difference between revisions of "Terraform modules"

From wikieduonline
Jump to navigation Jump to search
 
(22 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
Modules naming convention: <code>terraform-[[PROVIDER]]-NAME</code>
 
Modules naming convention: <code>terraform-[[PROVIDER]]-NAME</code>
 +
* <code>[[.terraform/modules/]]</code>
 +
 +
Update modules:
 +
* <code>[[terraform init -upgrade]]</code>
 +
 +
List modules and versions:
 +
* <code>[[cat .terraform/modules/modules.json]] | jq</code>
 +
 +
== Related commands ==
 +
* <code>[[terraform providers]]</code>
 +
* <code>[[terraform init]]</code>
 +
* <code>[[terraform init -upgrade]]</code>
 +
* <code>[[terraform get]]</code>
 +
* <code>[[terraform get -update]]</code>
 +
* <code>[[terraform graph]] 2>&1 | grep module | grep "{" |  cut -d"{" -f1</code>
 +
* <code>[[terraform get -update]] | grep Downloading</code>
  
 
== [[Terraform AWS modules|AWS modules]] ==
 
== [[Terraform AWS modules|AWS modules]] ==
 
{{tf AWS modules TOC}}
 
{{tf AWS modules TOC}}
 
== Hashicorp modules ==
 
* <code>[[hashicorp/random]]</code>
 
* <code>[[hashicorp/template]]</code> (deprecated)
 
  
 
== Others ==
 
== Others ==
Line 14: Line 26:
  
 
== Examples in [[main.tf]] ==
 
== Examples in [[main.tf]] ==
  [[Terraform modules|module]] "[[consul]]" {
+
  [[Terraform modules|module]] "[[yourconsul]]" {
 
   [[Terraform modules: source|source]] = "./path/to/you/module"
 
   [[Terraform modules: source|source]] = "./path/to/you/module"
 
  }
 
  }
Line 22: Line 34:
 
  }
 
  }
  
  module "[[ec2_instance]]" {
+
  module "[[your_ec2_instance]]" {
 
   source  = "[[terraform-aws-modules/]]ec2-instance/aws"
 
   source  = "[[terraform-aws-modules/]]ec2-instance/aws"
 
   [[version]] = "~> 3.0"
 
   [[version]] = "~> 3.0"
 
  }
 
  }
  
== Related commands ==
+
module "your_module" {
* <code>[[terraform providers]]</code>
+
  [[Terraform modules: source|source]] =  git::[email protected]:your-org/your-project.git?ref=[[your-branch]]
* <code>[[terraform init]]</code>
+
}
* <code>[[terraform init -upgrade]]</code>
+
 
* <code>[[terraform get]]</code>
+
== Errors ==
* <code>[[terraform get -update]]</code>
+
* <code>[[Error: Module not installed]]</code>
* <code>[[terraform graph]] 2>&1 | grep module | grep "{" |  cut -d"{" -f1</code>
+
* <code>[[Error: Unsupported argument]]</code>
* <code>[[terraform get -update]] | grep Downloading</code>
 
  
 
== Related terms ==
 
== Related terms ==
* [[Terraform modules: source]]
+
* [[Terraform modules:]] <code>[[Terraform modules: source|source]]</code>
 +
* [[Terraform module keyword]]
 
* [[Ansible modules]]
 
* [[Ansible modules]]
 
* [[Terraform resources]]
 
* [[Terraform resources]]
 
* [[Provider (Terraform)]]: <code>[[aws]]</code>
 
* [[Provider (Terraform)]]: <code>[[aws]]</code>
* <code>[[Error: Module not installed]]</code>
 
 
* [[Terraform registry]]: https://registry.terraform.io/browse/modules
 
* [[Terraform registry]]: https://registry.terraform.io/browse/modules
 
* [[AWS CloudFormation modules]] (Nov 2020)
 
* [[AWS CloudFormation modules]] (Nov 2020)
Line 48: Line 59:
 
* [[Still destroying]]
 
* [[Still destroying]]
 
* [[Learn-terraform-provision-eks-cluster: terraform providers]]
 
* [[Learn-terraform-provision-eks-cluster: terraform providers]]
* <code>[[.terraform/modules/]]</code>
+
* [[Terraform module keyword]]
 +
* <code>[[module.]]</code>
 +
* [[Standard module structure]]
 +
* [[Terraform modules inputs]]
 +
* <code>[[depends_on]]</code>
 +
* [[Terraform submodule]]
  
 
== See also ==
 
== See also ==

Latest revision as of 11:03, 30 May 2024

Modules naming convention: terraform-PROVIDER-NAME

Update modules:

List modules and versions:

Related commands[edit]

AWS modules[edit]

Others[edit]

Examples in main.tf[edit]

module "yourconsul" {
  source = "./path/to/you/module"
}
module "yourmodule" {
  source = "github.com/your-project/terraform-your-templates/modules/yourmodule"
}
module "your_ec2_instance" {
  source  = "terraform-aws-modules/ec2-instance/aws"
  version = "~> 3.0"
}
module "your_module" {
  source =  git::[email protected]:your-org/your-project.git?ref=your-branch
}

Errors[edit]

Related terms[edit]

See also[edit]

Advertising: