blue86321 / terraform-learn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Learn

This repo is a note to learn terraform. Four demos to make you familiar with terraform.

Prerequisites: basic knowledge of cloud ecosystem. e.g. VPC, Subnet, Internet Gateway, etc.

Intro

Terraform is a tool to automate infrastructure operations for cloud, data center services. We only need to configure the desired state of the infrastructure, Terraform will generate the execution plan in order and execute it.

For those who are totally new to terraform, learn basic concept of terraform and how to write simple terraform config in this tutorial.

Concepts covered:

  • terraform file (.tf)
    • provider
    • resource
    • data
    • variable
    • output
  • CLI operations
    • terraform init
    • terraform apply
    • terraform destroy
  • Set variables
    • .tfvars
    • environment variables

For those who have basic knowledge of terraform, and want to know how to run an actual project on AWS.

Resources covered:

  • VPC
  • Subnet
  • Route Table and Internet Gateway
  • Security Group (SSH, browser. traffic in and out of EC2 instance)
  • EC2 instances (nginx)

The same as Nginx Demo, but modularize the configuration to make the structure much clear.

Typical project structure:

.
├── modules
│   └── [module-name]
│       ├── main.tf
│       ├── outputs.tf
│       ├── providers.tf
│       └── variables.tf
├── main.tf
├── outputs.tf
├── providers.tf
└── variables.tf

The same as Nginx Demo Module, but not only modularize it, we also use existing modules from Terraform Registry. In addition, we store terraform state on S3 to make sure all related repositories are using the same terraform state.

About

License:MIT License


Languages

Language:HCL 93.7%Language:Shell 6.3%