Terraform 07 - Terraform Modules
In this session, we discussed about Terraform Module for improving code reusability. References: https://github.com/terraform-aws-modules Timestamps: 0:00 - Intro 7:35 - demo1 module from GitHub 17:17 - demo2 Create your own module ________________________________________________________________________ main.tf for tf_module_github module "ec2_cluster" { # copy and paste the source from Github and remove the https:// source = "github.com/terraform-aws-modules/terraform-aws-ec2-instance.git" name = "my-cluster" ami = "ami-0c2b8ca1dad447f8a" instance_type = "t2.micro" subnet_id = "subnet-920091cd" tags = { terraform = true environment = "dev" } } ________________________________________________________________________ vpc.tf for tf_module_local resource "aws_vpc" "aws-vpc-custom" { cidr_block = var.cidr instance_tenancy = var.instance_tenancy enable_dns_hostnames = var.enable_dns_hostnames enable_dns_support = var.enable_dns_support enable_classiclink = var.enable_classiclink enable_classiclink_dns_support = var.enable_classiclink_dns_support assign_generated_ipv6_cidr_block = var.enable_ipv6 tags = { name = var.vpcname environment = var.vpcenvironment } } main.tf for tf_module_local/QA module "qa-vpc" { source = "../../tf_module_local" vpcname = "qa01-vpc" cidr = "10.0.3.0/24" enable_dns_support = true enable_classiclink = false enable_classiclink_dns_support = false enable_ipv6 = true vpcenvironment = "qa" AWS_REGION = "us-west-1" } main.tf for tf_module_local/Dev module "dev-vpc" { source = "../../tf_module_local" vpcname = "dev01-vpc" cidr = "10.0.2.0/24" enable_dns_support = true enable_classiclink = false enable_classiclink_dns_support = false enable_ipv6 = true vpcenvironment = "dev" } #terraform #automation #infrastructureascode #AWS #zzTALK
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.