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_vpc_net_facts] Fix UnsupportedOperation for regions other than u… #35302
[ec2_vpc_net_facts] Fix UnsupportedOperation for regions other than u… #35302
Conversation
@@ -193,12 +193,18 @@ def describe_vpcs(connection, module): | |||
|
|||
# We can get these results in bulk but still needs two separate calls to the API | |||
try: | |||
cl_enabled = connection.describe_vpc_classic_link(VpcIds=vpc_list) | |||
if connection._client_config.region_name != 'us-east-1': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just catch the unsupported operation exception and ignore it. No need to do region checking.
except botocore.exceptions.ClientError as e: | ||
module.fail_json(msg=e.message, exception=traceback.format_exc(), **camel_dict_to_snake_dict(e.response)) | ||
|
||
try: | ||
cl_dns_support = connection.describe_vpc_classic_link_dns_support(VpcIds=vpc_list) | ||
if connection._client_config.region_name != 'us-east-1': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed! Also updated the exception handling for the rest of the module so it is Python 3 compatible and handles BotoCoreError.
The exception handling for BotoCoreError and ClientError just looks like a good time to move to AnsibleAWSModule and fail_json_aws and let that deal with the differences. |
I'm also eyeing this for a backport, so I'd rather not introduce a migration too since AnsibleAWSModule doesn't inherit from AnsibleModule & lacks some of the API. Instead of a migration, I like the slightly more verbose but simpler new exception handling. |
rebuild_merge |
ansible#35302) * [ec2_vpc_net_facts] Fix UnsupportedOperation for regions other than us-east-1 * Make fix more Pythonic * Fix the exception handling for the module
…s-east-1
SUMMARY
Fixes
After fix:
ISSUE TYPE
COMPONENT NAME
lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py
ANSIBLE VERSION