Use case:
Export list of snapshots in txt file (old_snapshots.txt) to S3 bucket. From Jenkins, use aws cp command copy file to Jenkins /tmp/directory
--dry-run did not show any error
However, when passed the following bash line with aws delete command in Jenkins it shows SUCCESS, at the same says error has occurred and the snapshots are not deleted.
## actual deletion
file="/tmp/old_snapshots.txt"
while read delete_data
do
aws ec2 --region eu-west-1 delete-snapshot --snapshot-id $file
echo "Deleting snapshot $delete_data"
done <"$file"
Output
An error occurred (InvalidParameterValue) when calling the DeleteSnapshot operation: Value (/tmp/old_snapshots.txt) for parameter snapshotId is invalid. Expected: 'snap-...'.
Deleting snapshot snap-xxxx81xxxxxx7fxxx
An error occurred (InvalidParameterValue) when calling the DeleteSnapshot operation: Value (/tmp/old_snapshots.txt) for parameter snapshotId is invalid. Expected: 'snap-...'.
Deleting snapshot snap-xxxacc49xxxxxxc26
An error occurred (InvalidParameterValue) when calling the DeleteSnapshot operation: Value (/tmp/old_snapshots.txt) for parameter snapshotId is invalid. Expected: 'snap-...'.
Deleting snapshot snap-04xxxxxxxx3fa3cxxxxxxf4
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Request: This error An error occurred (InvalidParameterValue) when calling the DeleteSnapshot operation
seems too generic? Have anyone experienced seem issue? Also, I did a manual test of deleting just a single snapshot with aws cli by manually adding the snapshot id in Jenkins and that works fine. Any suggestion would be greatly appreciated.
Including aws command
aws ec2 --region eu-west-1 delete-snapshot --snapshot-id snap-01x1618xxxxxxa51x
Found snapshotid: snap-01x1618xxxxxxa51x in the uploaded file: /tmp/old_snapshots.txt
Now deleting snapshot id snap-01x1618xxxxxxa51x