Current argument parsing does not seem to be able to process Glacier archiveID's which start with a dash (hyphen).
Escaping and using bash builtin "--" to notify of no further command options does not work.
The uskudnik/amazon-glacier-cmd-interface project takes the approach of preceding hyphen-leading archiveID's with --.
Examples:
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id "-test"
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --archive-id: expected one argument
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id '-test'
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --archive-id: expected one argument
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id '\-test'
A client error (Unknown) occurred when calling the DeleteArchive operation:
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id "\-test"
A client error (Unknown) occurred when calling the DeleteArchive operation:
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id \-test
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --archive-id: expected one argument
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id -- \-test
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --archive-id: expected one argument
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id -- "-test"
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --archive-id: expected one argument
> aws glacier delete-archive --account-id - --vault-name myvault --archive-id -- "\-test"
usage: aws [options] <command> <subcommand> [parameters]
aws: error: argument --archive-id: expected one argument
Yeah having a dash in front of a value proves to be an issue from time to time, and would be difficult to fix as the issue sources itself from python's ArgParser
.
The good news is that I believe you can get around this issue by using param files. So save the text -text
to some file say myarchive.txt
. And then run:
aws glacier delete-archive --account-id - --vault-name myvault --archive-id file://myarchive.txt
Let me know if that is a good work around for you.
Hey Kyle,
That should work as a work around for now. Thanks for the response!
I've had the same problem and I tried the suggested workaround which still failed for me (I got the same 'unknown client error' as when trying to delete the archive using '-test')
However, I solved the issue by using the JSON parameter input method instead of the normal command-line inputs:
aws glacier delete-archive --account-id - --vault-name myvault --cli-input-json '{"archiveId": "-test"}'
Hope that helps anyone else who has been frustrated with this problem
Just wanted to note here that you can also use a different argument syntax here (i.e., name='value'
). For example:
aws glacier delete-archive --account-id '-' --vault-name myvault --archive-id='-test'
The help documents should be updated to reflect this commonly encountered issue with the aws glacier CLI tools. Having it as a default method of specifying the id's would hopefully prevent people from encountering this in the future.
@h110hawk +1
@mtdowling thanks! That worked for me.
The other solution in this thread (creating a file with the archive ID) is pretty cumbersome if you're deleting a large number of archives, though I suppose you could script either solution.
Most helpful comment
Just wanted to note here that you can also use a different argument syntax here (i.e.,
name='value'
). For example: