Aws-cli: Can't delete Glacier archive if ID starts with `-`

Created on 13 Mar 2017  路  2Comments  路  Source: aws/aws-cli

Trying to delete a Glacier archive is impossible if the archive ID starts with a -:

$ aws glacier delete-archive --debug --account-id - --vault-name test-vps --archive-id -p1N7QVecWTRj7iCIdA48btprxGKbqsetQ8CugQ75zgmXPkfpo4JFFuAjuXi_lD7Io3okedYW_SbXUAwhH6U_CofMkMSO_LedzyICvXdli2Q8FDuc6qiZjFiZbLogFVSOFg11Y5zZA
2017-03-13 09:31:42,070 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-66-generic botocore/1.4.70
2017-03-13 09:31:42,071 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['glacier', 'delete-archive', '--debug', '--account-id', '-', '--vault-name', 'test-vps', '--archive-id', '-p1N7QVecWTRj7iCIdA48btprxGKbqsetQ8CugQ75zgmXPkfpo4JFFuAjuXi_lD7Io3okedYW_SbXUAwhH6U_CofMkMSO_LedzyICvXdli2Q8FDuc6qiZjFiZbLogFVSOFg11Y5zZA']
2017-03-13 09:31:42,071 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x7fd094ed0048>
2017-03-13 09:31:42,071 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x7fd093c800d0>
2017-03-13 09:31:42,071 - MainThread - botocore.credentials - DEBUG - Skipping environment variable credential check because profile name was explicitly set.
2017-03-13 09:31:42,072 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python3/dist-packages/botocore/data/glacier/2012-06-01/service-2.json
2017-03-13 09:31:42,076 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.glacier: calling handler <function register_retries_for_service at 0x7fd0940e09d8>
2017-03-13 09:31:42,076 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: glacier
2017-03-13 09:31:42,077 - MainThread - botocore.hooks - DEBUG - Event building-command-table.glacier: calling handler <function add_waiters at 0x7fd094ed6400>
2017-03-13 09:31:42,079 - MainThread - awscli.clidriver - DEBUG - OrderedDict([('account-id', <awscli.arguments.CLIArgument object at 0x7fd0936a4978>), ('vault-name', <awscli.arguments.CLIArgument object at 0x7fd0936a49b0>), ('archive-id', <awscli.arguments.CLIArgument object at 0x7fd0936a49e8>)])
2017-03-13 09:31:42,079 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.glacier.delete-archive: calling handler <function add_streaming_output_arg at 0x7fd094ed02f0>
2017-03-13 09:31:42,079 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.glacier.delete-archive: calling handler <function add_cli_input_json at 0x7fd093c80a60>
2017-03-13 09:31:42,079 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.glacier.delete-archive: calling handler <function unify_paging_params at 0x7fd09390e730>
2017-03-13 09:31:42,081 - MainThread - botocore.loaders - DEBUG - Loading JSON file: /usr/lib/python3/dist-packages/botocore/data/glacier/2012-06-01/paginators-1.json
2017-03-13 09:31:42,081 - MainThread - botocore.hooks - DEBUG - Event building-argument-table.glacier.delete-archive: calling handler <function add_generate_skeleton at 0x7fd0938f9730>
2017-03-13 09:31:42,081 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.glacier.delete-archive: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.cliinputjson.CliInputJSONArgument object at 0x7fd0936a4a20>>
2017-03-13 09:31:42,081 - MainThread - botocore.hooks - DEBUG - Event before-building-argument-table-parser.glacier.delete-archive: calling handler <bound method OverrideRequiredArgsArgument.override_required_args of <awscli.customizations.generatecliskeleton.GenerateCliSkeletonArgument object at 0x7fd0936a4b00>>
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help
aws: error: argument --archive-id: expected one argument
$ aws --version
aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-66-generic botocore/1.4.70
closing-soon guidance

Most helpful comment

This is an artifact of argparse, it sees the dash and assumes you're providing an argument. Try using the equality syntax, that should work:

--archive-id="-foobar"

All 2 comments

This is an artifact of argparse, it sees the dash and assumes you're providing an argument. Try using the equality syntax, that should work:

--archive-id="-foobar"

Cool! In that works, then it should make it into the docs and aws help content.

Was this page helpful?
0 / 5 - 0 ratings