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

Commit

Permalink
Merge pull request #40 from gwright99/check_instance_tags_not_none
Browse files Browse the repository at this point in the history
Check instance_tags not empty
  • Loading branch information
wleepang authored Mar 11, 2022
2 parents e415e41 + 6e88326 commit fa85b17
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/create-ebs-volume
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,20 @@ function create_and_attach_volume() {

local volume=""
for i in $(eval echo "{0..$max_attempts}") ; do
# If only tags on resource are prefixed with `aws:` they will all be deleted and cause a parameter validation on
# TagSpecifications[0].Tags[0] error to be thrown since the payload is determined to be a string, not dictionary.
if [ ! -z $instance_tags ]; then
local tag_specification="ResourceType=volume,Tags=[$instance_tags,{Key=source-instance,Value=$instance_id},{Key=amazon-ebs-autoscale-creation-time,Value=$timestamp}]"
else:
local tag_specification="ResourceType=volume,Tags=[{Key=source-instance,Value=$instance_id},{Key=amazon-ebs-autoscale-creation-time,Value=$timestamp}]"
fi

local volume=$(\
aws ec2 create-volume \
--region $region \
--availability-zone $availability_zone \
$volume_opts \
--tag-specification "ResourceType=volume,Tags=[$instance_tags,{Key=source-instance,Value=$instance_id},{Key=amazon-ebs-autoscale-creation-time,Value=$timestamp}]" \
--tag-specification "$tag_specification" \
2> $tmpfile
)

Expand Down

0 comments on commit fa85b17

Please sign in to comment.