Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2_instance fails to check TagSpecification for None #1148

Closed
1 task done
mdaniel opened this issue Oct 10, 2022 · 3 comments · Fixed by #1151
Closed
1 task done

ec2_instance fails to check TagSpecification for None #1148

mdaniel opened this issue Oct 10, 2022 · 3 comments · Fixed by #1151
Assignees
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) python3 traceback

Comments

@mdaniel
Copy link

mdaniel commented Oct 10, 2022

Summary

When I try to launch an ec2 instance using amazon.aws.ec2_instance from collection version 3.4.0 through 5.0.0 inclusive it fails botocore validation with

    "msg": "Failed to create new EC2 instance: Parameter validation failed:\nInvalid type for parameter TagSpecifications, value: None, type: <class 'NoneType'>, valid types: <class 'list'>, <class 'tuple'>"

This actually isn't directly my bug, I found it while triaging a StackOverflow question

The work-around appears to be to explicitly add tags: {} to the task parameters, but the DX is terrible if one does not know to do that

Issue Type

Bug Report

Component Name

ec2_instance

Ansible Version

$ ansible --version
ansible [core 2.13.4]
  config file = None
  configured module search path = ['/Users/mdaniel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/6.4.0/libexec/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/mdaniel/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.7 (main, Oct  2 2022, 21:54:06) [Clang 14.0.0 (clang-1400.0.29.102)]
  jinja version = 3.1.2
  libyaml = True

Collection Versions

$ ansible-galaxy collection list

# /Users/mdaniel/.ansible/collections/ansible_collections
Collection Version
---------- -------
amazon.aws 5.0.0

AWS SDK versions

$ pip show boto boto3 botocore
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.24.73
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /usr/local/Cellar/ansible/6.4.0/libexec/lib/python3.10/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.27.73
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /usr/local/Cellar/ansible/6.4.0/libexec/lib/python3.10/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: boto3, s3transfer

Configuration

$ ansible-config dump --only-changed
ANSIBLE_NOCOLOR(env: ANSIBLE_NOCOLOR) = True
ANSIBLE_NOCOWS(env: ANSIBLE_NOCOWS) = True
RETRY_FILES_ENABLED(env: ANSIBLE_RETRY_FILES_ENABLED) = False

OS / Environment

macOS 12.6

Steps to Reproduce

    amazon.aws.ec2_instance:
      key_name: stackkeypair
      image_id: ami-01216e7612243e0ef
      instance_type: t2.micro
      aws_region: ap-south-1
      wait: yes
      count: 1

Expected Results

I expected an instance to launch

Actual Results

  File "/usr/local/Cellar/ansible/6.4.0/libexec/lib/python3.10/site-packages/botocore/validate.py", line 381, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter TagSpecifications, value: None, type: <class 'NoneType'>, valid types: <class 'list'>, <class 'tuple'>

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@tremble
Copy link
Contributor

tremble commented Oct 11, 2022

Thanks for taking the time to open this issue.

I'm surprised this only just popped up. The issue was introduced by #548 and released in 2.1.0, almost a year ago!

softwarefactory-project-zuul bot pushed a commit that referenced this issue Oct 11, 2022
…n if None (#1151)

ec2_instance - update build_run_instance_spec to skip TagSpecification if None

SUMMARY
fixes: #1148
When no tags are supplied, build_run_instance_spec currently includes 'TagSpecification': None.  This results in botocore throwing an exception.
Also renames instance_role to iam_instance_profile (keeping the original as an alias).  While this could be split off, I'll just perform a partial backport for the bugfix when backporting to 4.x, while working through some unit tests the inaccuracy of the parameter name was apparent.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/modules/ec2_instance.py
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
patchback bot pushed a commit that referenced this issue Oct 12, 2022
…n if None (#1151)

ec2_instance - update build_run_instance_spec to skip TagSpecification if None

SUMMARY
fixes: #1148
When no tags are supplied, build_run_instance_spec currently includes 'TagSpecification': None.  This results in botocore throwing an exception.
Also renames instance_role to iam_instance_profile (keeping the original as an alias).  While this could be split off, I'll just perform a partial backport for the bugfix when backporting to 4.x, while working through some unit tests the inaccuracy of the parameter name was apparent.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/modules/ec2_instance.py
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
(cherry picked from commit a9ad180)
tremble added a commit to tremble/amazon.aws that referenced this issue Oct 12, 2022
…n if None (ansible-collections#1151)

ec2_instance - update build_run_instance_spec to skip TagSpecification if None

SUMMARY
fixes: ansible-collections#1148
When no tags are supplied, build_run_instance_spec currently includes 'TagSpecification': None.  This results in botocore throwing an exception.
Also renames instance_role to iam_instance_profile (keeping the original as an alias).  While this could be split off, I'll just perform a partial backport for the bugfix when backporting to 4.x, while working through some unit tests the inaccuracy of the parameter name was apparent.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/modules/ec2_instance.py
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
softwarefactory-project-zuul bot pushed a commit that referenced this issue Oct 13, 2022
…n if None (#1151) (#1160)

[PR #1151/a9ad1808 backport][stable-5] ec2_instance - update build_run_instance_spec to skip TagSpecification if None

This is a backport of PR #1151 as merged into main (a9ad180).
SUMMARY
fixes: #1148
When no tags are supplied, build_run_instance_spec currently includes 'TagSpecification': None.  This results in botocore throwing an exception.
Also renames instance_role to iam_instance_profile (keeping the original as an alias).  While this could be split off, I'll just perform a partial backport for the bugfix when backporting to 4.x, while working through some unit tests the inaccuracy of the parameter name was apparent.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/modules/ec2_instance.py
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) python3 traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants