Skip to content

Commit b4d4d74

Browse files
committed
Added support for deleting a volume with an S3 Access Point.
1 parent fa695b4 commit b4d4d74

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Management-Utilities/fsx-ontap-aws-cli-scripts/delete_fsxn_volume

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ EOF
3535
################################################################################
3636
waitForS3ApDelete () {
3737

38-
local s3apName=$1
38+
local s3ApName=$1
39+
local volumeId=$2
3940
local MaxIterations=60
4041
local SleepTime=5
4142
#
@@ -46,7 +47,7 @@ waitForS3ApDelete () {
4647
if [ $? -eq 0 ]; then
4748
status=$(jq -r .S3AccessPointAttachments[0].Lifecycle $tmpout 2> /dev/null)
4849
if [ "$status" != "DELETING" -a "$status" != "PENDING" ]; then
49-
printf "\nError, failed to delete volume with volume ID '$volumeId'. Status = ${status}.\n" 1>&2
50+
printf "\nError, failed to delete volume S3 endpoint $s3ApName attached to volume ID '$volumeId'. Status = ${status}.\n" 1>&2
5051
reason="$(jq -r '.S3AccessPointAttachments[0].LifecycleTransitionReason.Message' $tmpout 2> /dev/null)"
5152
if [ ! -z "$reason" ]; then
5253
echo "Reason: $reason" 1>&2
@@ -156,14 +157,14 @@ fi
156157
aws fsx describe-s3-access-point-attachments --filter "Name=volume-id,Values=$volumeId" --region=$region --output=json > $tmpout 2>&1
157158
if [ "$(jq -r '.S3AccessPointAttachments | length' $tmpout 2>&1)" != "0" ]; then
158159
while read s3apName; do
159-
[ $quiet != "true" ] && print "S3 Access Point '$s3apName' is being deleted." 1>&2
160+
[ $quiet != "true" ] && printf "S3 Access Point '$s3apName' is being deleted." 1>&2
160161
aws fsx detach-and-delete-s3-access-point --name $s3apName --region=$region --output=json > $tmpout 2>&1
161-
if waitForS3ApDelete $s3apName; then
162+
if waitForS3ApDelete $s3apName $volumeId; then
162163
:
163164
else
164165
exit 1
165166
fi
166-
[ $quiet != "true" ] && print "\n"
167+
[ $quiet != "true" ] && printf "\n"
167168
done < <(jq -r '.S3AccessPointAttachments[] | .S3AccessPoint.ResourceARN | split("/")[1]' $tmpout 2>/dev/null)
168169
fi
169170

0 commit comments

Comments
 (0)