From f1b6d6046cf1033f20eba09fb177f0e5c1e8ca90 Mon Sep 17 00:00:00 2001 From: "W. Lee Pang" Date: Fri, 10 Jul 2020 21:39:31 -0700 Subject: [PATCH] add creation timestamp tag --- bin/create-ebs-volume | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/create-ebs-volume b/bin/create-ebs-volume index 3c73a1f..8df59b9 100755 --- a/bin/create-ebs-volume +++ b/bin/create-ebs-volume @@ -208,12 +208,13 @@ function create_and_attach_volume() { local volume_opts="--size $SIZE --volume-type $TYPE" if [ "$TYPE" == "io1" ]; then volume_opts="$volume_opts --iops $IOPS"; fi if [ "$ENCRYPTED" == "1" ]; then volume_opts="$volume_opts --encrypted"; fi + local timestamp=$(date "+%F %T UTC%z") # YYYY-mm-dd HH:MM:SS UTC+0000 local volume=$(\ aws ec2 create-volume \ --region $region \ --availability-zone $availability_zone \ $volume_opts \ - --tag-specification "ResourceType=volume,Tags=[{Key=source-instance,Value=$instance_id}]" \ + --tag-specification "ResourceType=volume,Tags=[{Key=source-instance,Value=$instance_id},{Key=amazon-ebs-autoscale-creation-time,Value=$timestamp}]" \ 2> $tmpfile ) local volume_id=`echo $volume | jq -r '.VolumeId'`