aws / aws/aws-cli

ec2 subcommand fails when given --tag-specifications

Open
#8,720 1 comment 0 reactions 0 assignees View on GitHub
bug documentation ec2 p2
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the bug

This is a reopening of Issue #8211. Was able to verify that the behavior is present on multiple 2.x versions of the CLI across multiple operating systems.

### Expected Behavior

AWS CLI commands should work when following the published documentation.

### Current Behavior

AWS CLI command created following the published documentation fails with an unexpected error.

### Reproduction Steps

```
# aws-cli/2.16.0 Python/3.11.9 Darwin/23.5.0 source/arm64
# Example from documentation with the only changes being specific VPC ID and CIDR block
aws ec2 create-subnet --vpc-id vpc-0d54e6a6aee42292c --cidr-block 10.21.16.0/20 --tag-specifications ResourceType=subnet,Tags=[{Key=Name,Value=my-ipv4-only-subnet}] --debug --region us-east-1
...
2024-06-04 14:02:12,031 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 499, in main
return command_table[parsed_args.command](remaining, parsed_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 634, in __call__
return command_table[parsed_args.operation](remaining, parsed_globals)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 837, in __call__
return self._operation_caller.invoke(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 963, in invoke
response = self._make_client_call(
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/clidriver.py", line 975, in _make_client_call
response = getattr(client, xform_name(operation_name))(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/botocore/client.py", line 360, in _api_call
return self._make_api_call(operation_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/botocore/client.py", line 701, in _make_api_call
request_dict = self._convert_to_request_dict(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/botocore/client.py", line 764, in _convert_to_request_dict
request_dict = self._serializer.serialize_to_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/awscli/2.16.0/libexec/lib/python3.11/site-packages/awscli/botocore/validate.py", line 336, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter TagSpecifications[0].Tags[0], value: Key=Name, type: , valid types:
Invalid type for parameter TagSpecifications[1].Tags[0], value: Value=my-ipv4-only-subnet, type: , valid types:

Parameter validation failed:
Invalid type for parameter TagSpecifications[0].Tags[0], value: Key=Name, type: , valid types:
Invalid type for parameter TagSpecifications[1].Tags[0], value: Value=my-ipv4-only-subnet, type: , valid types:
```

```
# aws-cli/2.15.58 Python/3.11.8 Linux/6.1.90-99.173.amzn2023.x86_64 exec-env/CloudShell exe/x86_64.amzn.2023
aws ec2 create-subnet --vpc-id vpc-0d54e6a6aee42292c --cidr-block 10.21.16.0/20 --tag-specifications ResourceType=subnet,Tags=[{Key=Name,Value=my-ipv4-only-subnet}] --debug
...
2024-06-04 21:10:42,297 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
File "awscli/clidriver.py", line 499, in main
File "awscli/clidriver.py", line 634, in __call__
File "awscli/clidriver.py", line 837, in __call__
File "awscli/clidriver.py", line 963, in invoke
File "awscli/clidriver.py", line 975, in _make_client_call
File "awscli/botocore/client.py", line 360, in _api_call
File "awscli/botocore/client.py", line 701, in _make_api_call
File "awscli/botocore/client.py", line 764, in _convert_to_request_dict
File "awscli/botocore/validate.py", line 336, in serialize_to_request
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter TagSpecifications[0].Tags[0], value: Key=Name, type: , valid types:
Invalid type for parameter TagSpecifications[1].Tags[0], value: Value=my-ipv4-only-subnet, type: , valid types:

Parameter validation failed:
Invalid type for parameter TagSpecifications[0].Tags[0], value: Key=Name, type: , valid types:
Invalid type for parameter TagSpecifications[1].Tags[0], value: Value=my-ipv4-only-subnet, type: , valid types:
```

Fully double quoting the argument to `tag-specifications` results in a successful invocation on both platforms.

Full debug log from MacOS is attached.
[debug-log-macos.txt](https://github.com/user-attachments/files/15570539/debug-log-macos.txt)

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CLI version used

Multiple (see repro)

### Environment details (OS name and version, etc.)

Multiple (see repro)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.