Version: aws-cli/1.16.18 Python/3.7.0 Windows/7 botocore/1.12.8
When attempting to run either sam deploy
or aws cloudformation deploy
the following error occurs:
aws cloudformation deploy --template-file packaged.yml --stack-name my-stack --parameters uat.json --profile uat --region us-east-1
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws.cmd: error: argument subcommand: Invalid choice, valid choices are:
push | register
deregister | install
uninstall
This happens as long as the required variables are set. If they aren't set I get the correct error message:
$ aws cloudformation deploy
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: the following arguments are required: --template-file, --stack-name
but if I even use dummy variables:
$ aws cloudformation deploy --template-file abc.json --stack-name mystack
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 subcommand: Invalid choice, valid choices are:
push | register
deregister | install
uninstall
These seem to be command choices from aws deploy
not aws cloudformation deploy
.
Full debug output:
$ aws cloudformation deploy --debug --template-file abc.json --stack-name my stack
2018-09-21 12:05:15,230 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.16.18 Python/3.7.0 Windows/7 botocore/1.12.8
2018-09-21 12:05:15,232 - MainThread - awscli.clidriver - DEBUG - Arguments entered to CLI: ['cloudformation', 'deploy', '--debug', '--template-file', 'abc.json', '--stack-name', 'my', 'stack']
2018-09-21 12:05:15,236 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function add_scalar_parsers at 0x00000000042092F0>
2018-09-21 12:05:15,237 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,237 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function register_uri_param_handler at 0x0000000003C1A8C8>
2018-09-21 12:05:15,249 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,250 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function inject_assume_role_provider_cache at 0x0000000003C4CBF8>
2018-09-21 12:05:15,252 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,253 - MainThread - botocore.session - DEBUG - Loading variable credentials_file from defaults.
2018-09-21 12:05:15,254 - MainThread - botocore.session - DEBUG - Loading variable config_file from defaults.
2018-09-21 12:05:15,255 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,256 - MainThread - botocore.session - DEBUG - Loading variable metadata_service_timeout from defaults.
2018-09-21 12:05:15,257 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,258 - MainThread - botocore.session - DEBUG - Loading variable metadata_service_num_attempts from defaults.
2018-09-21 12:05:15,270 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,271 - MainThread - botocore.hooks - DEBUG - Event session-initialized: calling handler <function attach_history_handler at 0x0000000003F8F268>
2018-09-21 12:05:15,273 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,274 - MainThread - botocore.session - DEBUG - Loading variable profile from defaults.
2018-09-21 12:05:15,274 - MainThread - botocore.session - DEBUG - Loading variable api_versions from defaults.
2018-09-21 12:05:15,278 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\python37\lib\site-packages\botocore\data\cloudformation\2010-05-15\service-2.json
2018-09-21 12:05:15,287 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.cloudformation: calling handler <function register_retries_for_service at 0x0000000003966510>
2018-09-21 12:05:15,289 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: cloudformation
2018-09-21 12:05:15,293 - MainThread - botocore.hooks - DEBUG - Event building-command-table.cloudformation: calling handler <function inject_commands at 0x0000000003C53EA0>
2018-09-21 12:05:15,295 - MainThread - botocore.hooks - DEBUG - Event building-command-table.cloudformation: calling handler <function add_waiters at 0x0000000004210598>
2018-09-21 12:05:15,363 - MainThread - botocore.loaders - DEBUG - Loading JSON file: C:\python37\lib\site-packages\botocore\data\cloudformation\2010-05-15\waiters-2.json
2018-09-21 12:05:15,366 - MainThread - botocore.hooks - DEBUG - Event building-command-table.deploy: calling handler <function inject_commands at 0x0000000003EECBF8>
2018-09-21 12:05:15,367 - MainThread - botocore.hooks - DEBUG - Event building-command-table.deploy: calling handler <function add_waiters at 0x0000000004210598>
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 subcommand: Invalid choice, valid choices are:
push | register
deregister | install
uninstall
I discovered the reason that I was having this issue is because there is no --parameters
flag that accepts a file input (aws cloudformation create-stack and many other cli commands do accept this). The only way to specify parameters for this command is by --parameter-overrides
and passing them in as Key=Value,Key1=Value1.
There should be a way to pass a file input to this command. We have a long list of parameters we need to pass into this function and would like to store them in source control, being able to simply store them in environment-specific files would be really nice.
@zakkl13 - Thanks for reaching out. Looks like using file://
with the --parameter-overrides
might be the best practice for this issue. Here's an example using a snippet from your previous post:
aws cloudformation deploy --template-file packaged.yml --stack-name my-stack --parameter-overrides file://C:\temp\list.json --profile uat --region us-west-2
Related AWS documentation: Specifying Parameter Values for the AWS Command Line Interface - AWS Command Line Interface
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
Most helpful comment
I discovered the reason that I was having this issue is because there is no
--parameters
flag that accepts a file input (aws cloudformation create-stack and many other cli commands do accept this). The only way to specify parameters for this command is by--parameter-overrides
and passing them in as Key=Value,Key1=Value1.There should be a way to pass a file input to this command. We have a long list of parameters we need to pass into this function and would like to store them in source control, being able to simply store them in environment-specific files would be really nice.