Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Archives for ebs

March 22, 2020

EBS DeleteOnTermination

Here’s how to set the DeleteOnTermination setting on EBS volumes. The DeleteOnTermination flag determines if an EBS volume will be kept or deleted when an EC2 instance is terminated. The DeleteOnTermination setting can be set during EC2 instance creation, or it can be applied to an existing or a running EC2 instance. The settings can be placed in a JSON file and loaded using –block-device-mappings option upon creation.

During creation.

aws ec2 run-instances \
--count 1 \
--region us-east-2 \
--key-name tfc-ohio \
--image-id ami-xxxxxxxx \
--instance-type t2.large \
--subnet-id subnet-xxxxxxx \
--private-ip-address 10.0.4.100 \
--iam-instance-profile Name=machinerole \
--security-group-ids sg-xxxxxxxxxxxxx \
--block-device-mappings file://mapping.json

aws ec2 run-instances \ --count 1 \ --region us-east-2 \ --key-name tfc-ohio \ --image-id ami-xxxxxxxx \ --instance-type t2.large \ --subnet-id subnet-xxxxxxx \ --private-ip-address 10.0.4.100 \ --iam-instance-profile Name=machinerole \ --security-group-ids sg-xxxxxxxxxxxxx \ --block-device-mappings file://mapping.json

Contents of mapping.json

[
  {
    "DeviceName": "/dev/sda1",
    "Ebs": {
      "DeleteOnTermination": true,
      "VolumeSize": 30
      "VolumeType": "gp2"
    }
  }
]

[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": true, "VolumeSize": 30 "VolumeType": "gp2" } } ]

Device name is /dev/sda1. Termination is set to true. Volume size is 30GB and EBS type is gp2.

Modifying an existing EC2 instance.

aws ec2 modify-instance-attribute \
--instance-id i-xxxxxxxxxxxxx \
--block-device-mappings file://mapping.json

aws ec2 modify-instance-attribute \ --instance-id i-xxxxxxxxxxxxx \ --block-device-mappings file://mapping.json

Here’s the mapping.json file.

[
  {
    "DeviceName": "/dev/sda1",
    "Ebs": {
      "DeleteOnTermination": false,
    }
  }
]

[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": false, } } ]

Obviously, you can’t change Volume size and type to an existing EBS volume, but you can flip the DeleteOnTermination flag and vice versa.

January 16, 2019

AWS Backup

AWS just introduced Backup, a new managed service for backing up AWS resources. You can now create backup policies of EC2, RDS, DynamoDB, and EFS systems. The default backup uses S3 buckets, but storage can be moved to Glacier or it can be expired. The backup service is initially available in Virginia, Ohio, Oregon and Ireland.

AWS Backup

October 10, 2018

Attach an EBS Volume to an Instance

Attaching an EBS volume to an existing instance is quite easy. You can easily add them via the AWS Console. With just a few clicks, you can add an EBS volume in no time. Just click the Create Volume button, indicate the size of the volume, choose which availability zone (preferably the same AZ where your instance resides), and enable encryption if you decide to do so. You can also add an EBS volume from an existing snapshot.

There are 2 steps to attaching an EBS volume to an existing instance.

Step 1. Attach an EBS volume.

How to attach an EBS to an existing Instance.

Step 2. Make the EBS volume available to your instance whether it’s Linux or Windows. This requires SSH access.

Making an EBS volume available to Linux.
Making an EBS volume available to Windows.

  • 1
  • 2
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021