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

Extended the wafv2_web_acl module with custom_response_bodies argument #721

Conversation

stefanhorning
Copy link
Contributor

@stefanhorning stefanhorning commented Sep 17, 2021

SUMMARY

Extended the wafv2_web_acl module to also take the custom_response_bodies argument, improved docs and extended tests

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

wafv2_web_acl

ADDITIONAL INFORMATION

Also touched docs of aws_waf_web_acl to make it easier to find the WAF v2 modules as I had trouble finding that at first.

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review feature This issue/PR relates to a feature request integration tests/integration module module needs_triage plugins plugin (any type) tests tests labels Sep 17, 2021
@stefanhorning
Copy link
Contributor Author

I believe I addressed all issues now. Let's see if build goes through now. Once green this should be ready to be merged.

@markuman
Copy link
Member

Sanity is failing

ERROR: Found 1 validate-modules issue(s) which need to be resolved:
ERROR: plugins/modules/wafv2_web_acl.py:0:0: return-syntax-error: RETURN.custom_response_bodies.returned: required key not provided @ data['custom_response_bodies']['returned']. Got None

@stefanhorning
Copy link
Contributor Author

stefanhorning commented Sep 20, 2021

Fixed RETURN docs now.

However I also noticed other CI errors in integration tests:

# ...
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "CustomResponseBodies", must be one of: Name, Scope, DefaultAction, Description, Rules, VisibilityConfig, Tags
Missing required parameter in Rules[2]: "VisibilityConfig"
Unknown parameter in Rules[2].Action.Block: "CustomResponse", must be one of: 
Unknown parameter in Rules[2].Statement: "VisibilityConfig", must be one of: ByteMatchStatement, SqliMatchStatement, XssMatchStatement, SizeConstraintStatement, GeoMatchStatement, RuleGroupReferenceStatement, IPSetReferenceStatement, RegexPatternSetReferenceStatement, RateBasedStatement, AndStatement, OrStatement, NotStatement, ManagedRuleGroupStatement
fatal: [testhost]: FAILED! => {
    "boto3_version": "1.15.0",
    "botocore_version": "1.18.0",
    "changed": false,
    "invocation": {
#    ...

This probably happens because of old boto or s.th. But what is weird that it also fails on params that were already there before my changes, such as VisibilityConfig.

@markuman
Copy link
Member

When newer botocore/boto3 versions are necessary, we can install them like https://github.com/mediafellows/community.aws/blob/wafv2_web_acl_improvements/tests/integration/targets/aws_msk_config/tasks/main.yml#L20
Can we determine somehow when custom_response_bodies was introduce to name the version in the documentation?

But what is weird that it also fails on params that were already there before my changes, such as VisibilityConfig.

Indeed, I have no idea atm.

@tremble
Copy link
Contributor

tremble commented Sep 20, 2021

@stefanhorning That may be a result of #644 landing and forcing the tests to run against the oldest version of botocore that we support, to highlight issues like this. Unfortunately if the code wasn't exercised before the tests wouldn't highlight the issue...

We actually have an even easier way to setup the boto3 pip installation (I still need to refactor community.aws)

https://github.com/ansible-collections/amazon.aws/blob/main/tests/integration/targets/ec2_vol/meta/main.yml
https://github.com/ansible-collections/amazon.aws/blob/main/tests/integration/targets/ec2_vol/tasks/main.yml#L387

@stefanhorning
Copy link
Contributor Author

I will try to use the pip role then. I am unfortunately not yet sure which botocore version introduced this, just for the boto3 lib I know which version, it seems to be the 1.18.0. See https://boto3.amazonaws.com/v1/documentation/api/1.18.0/reference/services/wafv2.html#WAFV2.Client.create_web_acl

Should I also add a note to the module docs and/or a check for correct boto version in the code?

@tremble
Copy link
Contributor

tremble commented Sep 20, 2021

try botocore 1.20.40

That seems to be to 'blame' for the CustomResponseBodies definition:
git blame botocore/data/wafv2/2019-07-29/service-2.json

071e4df826 (aws-sdk-python-automation 2021-03-29 18:09:32 +0000 1520)     "CustomResponseBodies":{
071e4df826 (aws-sdk-python-automation 2021-03-29 18:09:32 +0000 1521)       "type":"map",
071e4df826 (aws-sdk-python-automation 2021-03-29 18:09:32 +0000 1522)       "key":{"shape":"EntityName"},
071e4df826 (aws-sdk-python-automation 2021-03-29 18:09:32 +0000 1523)       "value":{"shape":"CustomResponseBody"},
071e4df826 (aws-sdk-python-automation 2021-03-29 18:09:32 +0000 1524)       "min":1
071e4df826 (aws-sdk-python-automation 2021-03-29 18:09:32 +0000 1525)     },

@stefanhorning
Copy link
Contributor Author

Ok, found out through github project that boto3 1.18.0 depends on botocore 1.21.0, see https://github.com/boto/boto3/blob/1.18.0/setup.cfg

So I will try with that

@tremble
Copy link
Contributor

tremble commented Sep 20, 2021

Once you determine the minimum requirements, please do update the docs and code to cleanly fail:

See for example:
https://github.com/ansible-collections/amazon.aws/blob/main/plugins/modules/ec2_vol.py#L719

    if module.params.get('throughput'):
        module.require_botocore_at_least('1.19.27', reason='to set the throughput for a volume')

@stefanhorning
Copy link
Contributor Author

Addressed all comments now I hope. Let's see what CI thinks.

@stefanhorning
Copy link
Contributor Author

Sorry, completely forgot about this PR. Have applied @tremble s suggestion now to check botocore version directly in main. Hope we are good to merge then (might still need a rebase though).

@stefanhorning
Copy link
Contributor Author

Got the extra test working now (for custom_response_bodies deletion). Also rebased on latest main to squash all irrelevant commits and get rid of merge commits.

So in my opinion this can finally get merged.

@ansibullbot ansibullbot added community_review and removed merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Feb 9, 2022
@markuman
Copy link
Member

markuman commented Feb 9, 2022

Got the extra test working now (for custom_response_bodies deletion). Also rebased on latest main to squash all irrelevant commits and get rid of merge commits.

So in my opinion this can finally get merged.

Ah one last change request.

You created an addition webacl. name: "{{ resource_prefix }}-acl-with-response-body"
This should also be removed in tests/integration/targets/wafv2/tasks/main.yml after line 68.

And you can verfiy the removal when you read-out the web acl again with its '_info` module

    - name: Web acl with custom response bodies verify removal of custom response
      assert:
        that:
          - acl_without_response_bodies is changed

Copy link
Contributor

@alinabuzachis alinabuzachis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefanhorning Thank you for taking time to work on this. I agree with @markuman suggested. Other than that, LGTM!

@stefanhorning
Copy link
Contributor Author

@markuman @alinabuzachis added the extra test and cleanup task now without breking the build again. 🎉
So I guess we are good now.

@markuman markuman added the mergeit Merge the PR (SoftwareFactory) label Feb 10, 2022
@markuman
Copy link
Member

111 conversations, that's a number :)
Thanks for your work @stefanhorning.
Thanks for reviewing @alinabuzachis

@stefanhorning
Copy link
Contributor Author

Yeah, it's probably the longest PR of all Ansible PRs that only add one param to a module. :)

@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit c91acf6 into ansible-collections:main Feb 10, 2022
@patchback
Copy link

patchback bot commented Feb 10, 2022

Backport to stable-3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-3/c91acf6a14c0aa69974241ead13223a84dbd5334/pr-721

Backported as #934

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Feb 10, 2022
#721)

Extended the wafv2_web_acl module with custom_response_bodies argument

SUMMARY
Extended the wafv2_web_acl module to also take the custom_response_bodies argument, improved docs and extended tests
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
wafv2_web_acl
ADDITIONAL INFORMATION
Also touched docs of aws_waf_web_acl to make it easier to find the WAF v2 modules as I had trouble finding that at first.

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Stefan Horning <None>
Reviewed-by: Mark Chappell <None>
Reviewed-by: Alina Buzachis <None>
(cherry picked from commit c91acf6)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Feb 10, 2022
#721) (#934)

[PR #721/c91acf6a backport][stable-3] Extended the wafv2_web_acl module with custom_response_bodies argument

This is a backport of PR #721 as merged into main (c91acf6).
SUMMARY
Extended the wafv2_web_acl module to also take the custom_response_bodies argument, improved docs and extended tests
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
wafv2_web_acl
ADDITIONAL INFORMATION
Also touched docs of aws_waf_web_acl to make it easier to find the WAF v2 modules as I had trouble finding that at first.
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
ec2_instance incr version added to 3.3.0 for added parameters

SUMMARY
CI problems in backport-3 ansible-collections#721
And we don't won't to stop 3.2.0 release.
Let's try to put/backport it for the next release.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
ec2_instance

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
…ctions#852)

ec2_instance: metadata_options version_added increased

SUMMARY
After CI troubles in the past, we've forget to backport this feature.

incr from 3.2.0 to 3.3.0 ansible-collections#763

failed backport 3 PR for 3.2.0 release ansible-collections#721


initial implementation for 3.2.0 ansible-collections#715

therefore no changelog fragment is necessary.
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_instance
ADDITIONAL INFORMATION

Reviewed-by: Jill R <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3 PR should be backported to the stable-3 branch community_review feature This issue/PR relates to a feature request integration tests/integration mergeit Merge the PR (SoftwareFactory) module module plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants