We will look at Terraform and have tf scripts for AWS- amazon cloud
Terraform is used for provision Software on cloud. We will used it on AMAZON Cloud
Install Terraform
Terraform is installed. Lets call terraform apply
Oops we got error . The .aws/config file had typo [[default]
Lets fix it by editing
and run again
Now we see
Overview
We can create variables of type and objects
- map
- list
- others
- resource
AWS provides resources or templates or customtypes. we can create variable from it like svredis
- provider — lets use aws
Map
use lookup( var.svvar, var.key, “defaultvalue”)
AWS REDIS SERVER
terraform apply. For multiple users the locking feature is there. Lets disable local and run
terraform plan -out ssvec2.out -lock=false
We get error
$ terraform init
now run
TERRAFORM -PEEK
Lets check the values of variables. use console
to quit
EXECUTE TERRAFORM SCRIPT
I provide good ami id now and run again
SUCCESS
STATE — AWS STATE
We used terraform for goal. We need to preserve the state of AWS. AWS CLI can create resources, IAM, SG and do all but we need to have the access to that welcome. lets see our ec2 server that we create
terraform show
Lets see the complete state. sweet I wanted to private-dns, private-ip, public-ip, network-interfaces all shows up and subnet too
AWS CONSOLE
Lets see this to see if the instance is there and if running. The creation timestamp shows this freshly brewed few seconds before.
ADD SECURITY GROUP
Edit Inbound Rule .Add ICMP Traffic
Now run SUCCESS
REMOTE STATE
Terraform tracks the Remote State in .tfstate
I changes the Remote or EC2 thru AWS Console. I want to save that
use terraform apply again. It will refresh its file and sync it
Lets see the state
terraform show
THE State is storeds
- local backend (default)
- s3
- consul
Lets see the state file .tfstate (terraform.tfstate)
delete the instance
terraform destroy
AWS Console
CONCLUSION
We created , saved ec2 server using Terraform.