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

Refactor s3_bucket_notifications to support SNS / SQS #940

Conversation

marknet15
Copy link
Contributor

@marknet15 marknet15 commented Feb 13, 2022

SUMMARY

Refactor s3_bucket_notifications to extend module to support the extra targets of SNS and SQS along with the currently supported Lambda functions.

Summary of changes:

  • Refactor module to support SNS/SQS targets along with current Lambda function support.
  • Fix check mode coverage
  • Update integration tests to more comprehensive cover functionality.
  • Update documentation in sns_topic and sqs_queue modules to add policy setting example.

Fixes: #140

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

s3_bucket_notifications

ADDITIONAL INFORMATION

https://boto3.amazonaws.com/v1/documentation/api/1.16.0/reference/services/s3.html#S3.Client.put_bucket_notification_configuration

@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 Feb 13, 2022
@softwarefactory-project-zuul
Copy link
Contributor

@softwarefactory-project-zuul
Copy link
Contributor

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.

@marknet15 Thank you. Can you please add a changelog fragment as well?

plugins/modules/s3_bucket_notification.py Outdated Show resolved Hide resolved
plugins/modules/s3_bucket_notification.py Outdated Show resolved Hide resolved
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.

@marknet15 Thank you. I only left one small suggestion, other than that LGTM!

plugins/modules/s3_bucket_notification.py Show resolved Hide resolved
@softwarefactory-project-zuul
Copy link
Contributor

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@alinabuzachis alinabuzachis added the backport-3 PR should be backported to the stable-3 branch label Mar 24, 2022
@markuman markuman added the mergeit Merge the PR (SoftwareFactory) label Mar 28, 2022
@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit dd89ed1 into ansible-collections:main Mar 28, 2022
@patchback
Copy link

patchback bot commented Mar 28, 2022

Backport to stable-3: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply dd89ed1 on top of patchback/backports/stable-3/dd89ed152413dad7b1d0a84049a9f647221eedb6/pr-940

Backporting merged PR #940 into main

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/ansible-collections/community.aws.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/stable-3/dd89ed152413dad7b1d0a84049a9f647221eedb6/pr-940 upstream/stable-3
  4. Now, cherry-pick PR Refactor s3_bucket_notifications to support SNS / SQS #940 contents into that branch:
    $ git cherry-pick -x dd89ed152413dad7b1d0a84049a9f647221eedb6
    If it'll yell at you with something like fatal: Commit dd89ed152413dad7b1d0a84049a9f647221eedb6 is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x dd89ed152413dad7b1d0a84049a9f647221eedb6
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Refactor s3_bucket_notifications to support SNS / SQS #940 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/stable-3/dd89ed152413dad7b1d0a84049a9f647221eedb6/pr-940
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

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

marknet15 added a commit to marknet15/community.aws that referenced this pull request Mar 28, 2022
…tions#940)

Refactor s3_bucket_notifications to support SNS / SQS

SUMMARY
Refactor s3_bucket_notifications to extend module to support the extra targets of SNS and SQS along with the currently supported Lambda functions.
Summary of changes:

Refactor module to support SNS/SQS targets along with current Lambda function support.
Fix check mode coverage
Update integration tests to more comprehensive cover functionality.
Update documentation in sns_topic and sqs_queue modules to add policy setting example.

Fixes: ansible-collections#140
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
s3_bucket_notifications
ADDITIONAL INFORMATION
https://boto3.amazonaws.com/v1/documentation/api/1.16.0/reference/services/s3.html#S3.Client.put_bucket_notification_configuration

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Woolley <mw@marknet15.com>
Reviewed-by: Markus Bergholz <git@osuv.de>
(cherry picked from commit dd89ed1)
marknet15 added a commit to marknet15/community.aws that referenced this pull request Mar 29, 2022
…tions#940)

Refactor s3_bucket_notifications to support SNS / SQS

SUMMARY
Refactor s3_bucket_notifications to extend module to support the extra targets of SNS and SQS along with the currently supported Lambda functions.
Summary of changes:

Refactor module to support SNS/SQS targets along with current Lambda function support.
Fix check mode coverage
Update integration tests to more comprehensive cover functionality.
Update documentation in sns_topic and sqs_queue modules to add policy setting example.

Fixes: ansible-collections#140
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
s3_bucket_notifications
ADDITIONAL INFORMATION
https://boto3.amazonaws.com/v1/documentation/api/1.16.0/reference/services/s3.html#S3.Client.put_bucket_notification_configuration

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Woolley <mw@marknet15.com>
Reviewed-by: Markus Bergholz <git@osuv.de>
marknet15 added a commit to marknet15/community.aws that referenced this pull request Mar 29, 2022
…tions#940)

Refactor s3_bucket_notifications to support SNS / SQS

SUMMARY
Refactor s3_bucket_notifications to extend module to support the extra targets of SNS and SQS along with the currently supported Lambda functions.
Summary of changes:

Refactor module to support SNS/SQS targets along with current Lambda function support.
Fix check mode coverage
Update integration tests to more comprehensive cover functionality.
Update documentation in sns_topic and sqs_queue modules to add policy setting example.

Fixes: ansible-collections#140
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
s3_bucket_notifications
ADDITIONAL INFORMATION
https://boto3.amazonaws.com/v1/documentation/api/1.16.0/reference/services/s3.html#S3.Client.put_bucket_notification_configuration

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Woolley <mw@marknet15.com>
Reviewed-by: Markus Bergholz <git@osuv.de>
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Mar 29, 2022
Backport: Refactor s3_bucket_notifications to support SNS / SQS (#940) - stable-3

SUMMARY
Backport #940 manually to resolve conflict
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
s3_bucket_notification
ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
More work on ELBv2 module_utils

SUMMARY

Refactors LB creation and makes sure that  ip_address_type is set on creation (bug found when working on fixing NLB tests)
Fixes bug with DefaultAction comparisons
Extends tests for _prune_ForwardConfig
Extends tests for _prune_secrets
Fixes KeyError bug uncovered when extending tests for _prune_secrets

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/module_utils/elbv2.py
ADDITIONAL INFORMATION
Fixes: ansible-collections#604
See also: ansible-collections#1365

Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
elbv2: respect UseExistingClientSecret

SUMMARY
Since amazon.aws 5.0.0, elb_application_lb runs into an exception, when using Type: authenticate-oidc in a rule, even when UseExistingClientSecret: True parameter is given. That works as expected with amazon.aws 4.x.x.
The logic gets broken in  ansible-collections#940
Basically AWS won't return both, UseExistingClientSecret and  ClientSecret.
But when requesting against boto3,  both parameters are mutually exclusive!
When the user set UseExistingClientSecret: True, the ClientSecret must be removed for the request.
When the user does not set UseExistingClientSecret or set it to False,  the UseExistingClientSecret must be included in the request.
While diving deeper, I've noticed a basic change detection problem for default values, that are not requested, but AWS will return them. I've summerized it in ansible-collections#1284
However, this PR does not target ansible-collections#1284, it just fixes the exception and restores the functionality and hotfix the change-detection only for Type: authenticate-oidc.
origin PR description

The error was: botocore.errorfactory.InvalidLoadBalancerActionException: An error occurred (InvalidLoadBalancerAction) when calling the ModifyRule operation: You must either specify a client secret or set UseExistingClientSecret to true

UseExistingClientSecret is not respected anymore since a.a 5
Introduced in ansible-collections#940
Furthermore, AWS returns also Scope and  SessionTimeout parameters that are filled with default values if not requested.
'Scope': 'openid',
'SessionTimeout': 604800,

That make the module always returns a change, if they are not requested.
This fix does not break backwards compatibility, because the values are already set by aws, when not requested yet.
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
plugins/module_utils/elbv2.yml
ADDITIONAL INFORMATION


          - Conditions:
              - Field: host-header
                Values:
                  - some.tld
              - Field: path-pattern
                Values:
                  - "/admin/*"
            Actions:
              - Type: authenticate-oidc
                Order: 1
                AuthenticateOidcConfig:
                  Issuer: https://login.microsoftonline.com/32rw-ewad53te-ef/v2.0
                  AuthorizationEndpoint: https://login.microsoftonline.com/324re-dafs6-6tw/oauth2/v2.0/authorize
                  TokenEndpoint: https://login.microsoftonline.com/432535ez-rfes-32543ter/oauth2/v2.0/token
                  UserInfoEndpoint: https://graph.microsoft.com/oidc/userinfo
                  ClientId: fasgd-235463-fsgd-243
                  ClientSecret: "{{ lookup('onepassword', 'some cool secret', vault='some important vault') }}"
                  SessionCookieName: AWSELBAuthSessionCookie
                  OnUnauthenticatedRequest: authenticate
                  UseExistingClientSecret: True
              - TargetGroupName: "{{ some_tg }}"
                Type: forward
                Order: 2

Reviewed-by: Alina Buzachis
Reviewed-by: Mark Chappell
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 has_issue integration tests/integration mergeit Merge the PR (SoftwareFactory) module module needs_maintainer plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for sns and sqs to s3_bucket_notification
4 participants