EBS Volumes

EBS volumes stands for Elastic Block Storage. This provides the means of storage for the EC2 instances that we are provisioning. By default every EC2 instance will get a default EBS storage instance with 8 GB. These default EBS storage will be terminated when the EC2 instance is deprovisioning.

In this section I will provision a new EC2 instance inside a VPC similar in previous section and then mount an EBS volume to it.

Create a file with the name vars.tf,

variable "AWS_REGION" {
  default = "eu-west-1"
}

variable "PATH_TO_PRIVATE_KEY" {
  default = "mykey"
}

variable "PATH_TO_PUBLIC_KEY" {
  default = "mykey.pub"
}

variable "AMIS" {
  type = map(string)
  default = {
    us-east-1 = "ami-13be557e"
    us-west-2 = "ami-06b94666"
    eu-west-1 = "ami-844e0bf7"
  }
}

Create a file with the name providers.tf,

Create a file with the name key.tf,

Create a file with the name vpc.tf,

Create a file with the name securitygroup.tf,

Create a file with the name instance.tf,

Last updated

Was this helpful?