Document

SUBSCRIBE TO GET FULL ACCESS TO THE E-BOOKS FOR FREE 🎁SUBSCRIBE NOW

Professional Dropdown with Icon

SUBSCRIBE NOW TO GET FREE ACCESS TO EBOOKS

Terraform Workspace

 

Terraform worksapces is a very logical concept where you can have multiple states of your infrastructure configuration. To put this in simple words if you are running an infrastructure configuration in development environment then the same infrastructure can be run in the production environment.

The main benefit of terraforming workspaces we get is we can have more than one state associated with a single terraform configuration.

  1.  
  2.  terraform workspace list
  3. terraform workspace new prod
  4. terraform workspace list
  5. terraform workspace new stag
  6. terraform workspace list
  7. terraform workspace select prod
  
provider "aws" {
profile="rprofile"
region="ap-south-1"
}

locals {
  instance_name = "${terraform.workspace}-instance"
}

resource "aws_instance" "ec2_example" {

    ami = "ami-04bde106886a53080"

    instance_type = "t2.micro"

    tags = {
      Name = local.instance_name
    }
}
Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *