Terraform is a open-source tool used to build, modify, and version control infratrucrure
provider.tf
):
Enables Terrafrom to interact with cloud providers and other APIsversions.tf
):
Sets version constaints for Terraform and optionally maps provides to a source address and version constaintvariable.tf
):
Input variables define reusable values and work like function arguments in general-purpose programming languagesmain.tf
):
Resource blocks describe infrastructure objects like VPCs, subnets, route tables, and gatewaysRun docker compose:
docker-compose run --rm terraform version
Run configure:
Provider (AWS): versions.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
Security credential variables: variables.tf
variable "access_key" {
type = string
sensitive = true
}
variable "secret_key" {
type = string
sensitive = true
}
variable "region" {
type = string
default = "ap-southeast-1"
}
Terraform init:
docker-compose run --rm terraform init