connecting Terraform Cloud to local machine
This Article Demonstrates How to connect a local Machine where we Installed Terraform and we connect it to Terraform cloud where resources will be Created at Terraform Cloud , and Logs will be Streamed at Local Machine.
purpose:
logs of terraform plan and terrafrom apply can be streamed to local and output can be vieed at cloud
procedure:
Login to app.Terraform.io and Create an organization
- create a workspace
- configure variables
create a file myfile.tf on our local machine
terraform { required_version = "~> 0.12" backend "remote" { organization = "rohit777"
workspaces { name = "myworkspace777" } }}resource aws_instance "myec2" { ami = "ami-096fda3c22c1c990a" instance_type = "t2.large"}
Create a file backend.hcl on our Local machine
workspaces { name = “myworkspace777” }
hostname = “app.terraform.io”
organization = “rohit777”
do terraform init on our Local Machine
terraform init -backend-config=”f.tf”
Execute terraform login command
The Screen shows as below
Do Terraform apply on our local machine
Resources can be seen Created at Terraform cloud
Goto Terraform cloud
And do confirm apply
The Screen will be as shown below
That’s Cool we have successfully connected our Terraform Cloud to Local amchine where we can see Resources are created at Terraform cloud and Logs can be seen at Local machine where Terraform is Installed.