Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
add creation timestamp tag
Browse files Browse the repository at this point in the history
  • Loading branch information
wleepang committed Jul 11, 2020
1 parent d0d76db commit f1b6d60
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/create-ebs-volume
Original file line number Diff line number Diff line change
Expand Up @@ -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'`
Expand Down

0 comments on commit f1b6d60

Please sign in to comment.