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

Logic for nested HttpRequestMethodConfig Values #188

Merged
merged 6 commits into from
Feb 3, 2021

Conversation

bradleypettit
Copy link
Contributor

SUMMARY

Fixes #187. Adds logic to the compare_condition function to suit when the 'Values' key is nested within 'HttpRequestMethodConfig'. Otherwise trying to access 'Values' directly throws "KeyError: 'Values'".

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

elbv2.py

ADDITIONAL INFORMATION

As per Boto docs, when condition Field is equal to 'http-request-method', the 'Values' list should then be nested within 'HttpRequestMethodConfig' dict.

@bradleypettit
Copy link
Contributor Author

I've found that the issue I was experiencing with HttpRequestMethodConfig applies to all other field categories with the exception of SourceIpConfig. SourceIpConfig already had a similar condition to the ones I have added for other fields.

Updated the linked issue with additional detail and updated this PR to resolve issue for all possible condition field options.

I believe this PR also fixes ansible-collections/community.aws#117

@bradleypettit
Copy link
Contributor Author

Found that while adding support for using HostHeaderConfig or PathPatternConfig I'd inadvertantly impacted cases when Values was defined directly instead.

This is specific to the Boto3 behaviour where Conditions['Values'] (Docs) is defined as "The condition value. Specify only when Field is host-header or path-pattern . Alternatively, to specify multiple host names or multiple path patterns, use HostHeaderConfig or PathPatternConfig ."

For example when _compare_condition is running against an ALB with an existing host-header field, the current_condition object is represented as:

{
'Field': 'host-header',
'HostHeaderConfig': { 'Values': ['host.1'] }
'Values': ['host.1']
}

As a result, my original update was then always trying to compare HostHeaderConfig['Values'], however it is expected that in ansible you can use either Values or HostHeaderConfig.

While I've used host-header (HostHeaderConfig) primarily in the above example - the same applies to path-pattern (PathPatternConfig).

To cater for both possible methods of configuration, I've updated the conditions to only use HostHeaderConfig or PathPatternConfig for comparison if both current_condition and condition contain the Config dict, otherwise fallback to the pre-existing Values compare.

@bradleypettit bradleypettit reopened this Dec 2, 2020
@gravesm gravesm added needs_verified Some one might want to take a look at this and reproduce it to confirm and removed needs_triage labels Dec 18, 2020
@goneri
Copy link
Member

goneri commented Jan 6, 2021

Hi @bradleypettit,

The patch indeed seems to fix ansible-collections/community.aws#117 too. I need more time to review it completely.
Thank you for your contribution! My goal is to get it merged quickly now.

@goneri
Copy link
Member

goneri commented Jan 8, 2021

I would like to land ansible-collections/community.aws#347 with this PR, there is a couple of CI-related issues to address first.

@goneri goneri removed the needs_verified Some one might want to take a look at this and reproduce it to confirm label Jan 8, 2021
@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review module_utils module_utils needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) labels Jan 13, 2021
goneri added a commit to goneri/community.aws that referenced this pull request Jan 19, 2021
@goneri
Copy link
Member

goneri commented Jan 19, 2021

This feature depends on boto3 June 13, 2019:

AWS::ElasticLoadBalancingV2::ListenerRule
In the RuleCondition property type:
Use the HostHeaderConfig property to specify information for a host header condition.
Use the HttpHeaderConfig property to specify information for an HTTP header condition.
Use the HttpRequestMethodConfig property to specify information for an HTTP method condition.
Use the PathPatternConfig property to specify information for a path pattern condition.
Use the QueryStringConfig property to specify information for a query string condition.
Use the SourceIpConfig property to specify information for a source IP condition.

See: https://forums.aws.amazon.com/thread.jspa?messageID=897663

goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 21, 2022
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 22, 2022
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
goneri pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 23, 2022
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 22, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Sep 22, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
mandar242 pushed a commit to mandar242/amazon.aws that referenced this pull request Sep 22, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 2, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 6, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 6, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 6, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 6, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 13, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 13, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 19, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 11, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 16, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 23, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 24, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 24, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Oct 24, 2024
…ollections#188)

* Migrate from boto3_conn to module.client
* Simplify error handling when creating connections
* Simplify Region handling
* Remove unused imports
* Changelog

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@6bdf00d
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 module_utils module_utils needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception modifying rule with existing HttpRequestMethodConfig
5 participants