First look at terraform

Terraform is client based like Ansible (which is good). Very cloud focussed and relies on Cloud API's to manage the infrastructure. This is good as it means you dont have to worry about authentication and ports etc but it does need to be a supported cloud vendor. You couldn't use it manage your own on-premise servers (presumably).

Example config file:

provider "aws" {
  access_key = "AKIAIFZVQTBBG3YF46LQ"
  secret_key = "SfEjiU0I2I7wxXQqbRWLPYCbEfdSxhI/4r44CgaV"
  region     = "us-east-1"
}

resource "aws_instance" "example" {
  ami           = "ami-2757f631"
  instance_type = "t2.micro"
}

> terraform init
> terraform apply
> terraform show 

Terraform is purely declarative. Ansible IS declarative but you need to be disciplined as it can be used imperatively.

One blog calls Terraform an 'orchestration' tool with ansible being a more traditional configuration management tool.

Some changes can be done in-place (~) but others, an obvious one being an image change, require a replacement (+/-).

> terraform destroy

Implicit dependencies are used to determine the order in which resources are created, eg, a ref from an elastic IP to a machine. That is, Terraform will infer that the machine needs to be created first and then the EIP. This is in fact the preferred way, for other case an explicit 'depends_on' property can be used.

PROVISIONERS are custom scripts that are run once when the resource is created, they are therefore only suited bootstrapping a server and NOT suited to config management. If CM is needed, then it should be bootstrapped here. If provisioning fails, the resource is marked as TAINTED, not rollback but will be destroyed and recreated on the next execution plan.

Variables can be used for inputs and outputs.

Comments

Popular posts from this blog

A brief look into Cloudformation