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

Add s3_bucket_notification module #58059

Merged
merged 1 commit into from
Jul 18, 2019
Merged

Add s3_bucket_notification module #58059

merged 1 commit into from
Jul 18, 2019

Conversation

aljazkosir
Copy link
Contributor

@aljazkosir aljazkosir commented Jun 19, 2019

SUMMARY

PR to introduce lambda_bucket_event module.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME
  • lib/ansible/modules/cloud/amazon/lambda_bucket_event.py
  • test/units/modules/cloud/amazon/test_lambda_bucket_event.py
ADDITIONAL INFORMATION

This module allows the management of AWS Lambda function bucket event mappings via the Ansible framework. Use module lambda to manage the lambda function itself, lambda_alias to manage function aliases and lambda_policy to modify lambda permissions.

Example:

---
# Example that creates a lambda event notification for a bucket
- hosts: localhost
  gather_facts: no
  tasks:
  - name: Process jpg image
    s3_bucket_notification:
      state: present
      event_name: on_jpg_add_or_remove
      bucket_name: test-bucket
      function_name: arn:aws:lambda:us-east-2:525810310200:function:test-lambda
      events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]
      prefix: images/
      suffix: .jpg

@ansibot
Copy link
Contributor

ansibot commented Jun 19, 2019

@aljazkosir, just so you are aware we have a dedicated Working Group for aws.
You can find other people interested in this in #ansible-aws on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 aws cloud core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jun 19, 2019
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jun 20, 2019
@aljazkosir
Copy link
Contributor Author

bot_status

@ansibot
Copy link
Contributor

ansibot commented Jun 23, 2019

Components

lib/ansible/modules/cloud/amazon/lambda_bucket_event.py
support: community
maintainers:

test/units/modules/cloud/amazon/test_lambda_bucket_event.py
support: core
maintainers:

Metadata

waiting_on: ansible
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
too many files or commits: False
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 0
ansible_shipits (core team members): 0
shipit_actors (maintainer or core team member): []
shipit_actors_other: []
automerge: automerge shipit test failed

click here for bot help

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 1, 2019
@aljazkosir aljazkosir closed this Jul 1, 2019
@aljazkosir aljazkosir reopened this Jul 1, 2019
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 1, 2019
@aljazkosir
Copy link
Contributor Author

ready_for_review

@willthames
Copy link
Contributor

This module seems the wrong approach - I'd prefer that this was just a parameter in the s3_bucket module

@ansibot
Copy link
Contributor

ansibot commented Jul 11, 2019

The test ansible-test sanity --test future-import-boilerplate [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/lambda_bucket_event.py:0:0: missing: from __future__ import (absolute_import, division, print_function)

The test ansible-test sanity --test metaclass-boilerplate [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/lambda_bucket_event.py:0:0: missing: __metaclass__ = type

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 11, 2019
@aljazkosir aljazkosir closed this Jul 11, 2019
@aljazkosir aljazkosir reopened this Jul 11, 2019
@aljazkosir aljazkosir closed this Jul 11, 2019
@aljazkosir aljazkosir reopened this Jul 11, 2019
@mattclay mattclay added the needs_ci_update This PR is blocked as it requires an update to CI infrastructure before tests can pass in CI. label Jul 11, 2019
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jul 16, 2019
@aljazkosir
Copy link
Contributor Author

@willthames I updated the arguments and added test that checks that order of events doesn't matter

description:
- Name of the function alias. Mutually exclusive with C(version).
required: false
aliases: ['lambda_alias']
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just call this argument lambda_alias without the alias (just thinking about future proofing for other notification targets)

required: false
aliases: ['lambda_alias']
type: str
version:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just call this argument lambda_version without the alias (just thinking about future proofing for other notification targets)

@@ -0,0 +1,2 @@
cloud/aws
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to make the test suite name match the module name. I don't mind if that's adding aws_ to the module name or removing aws_ from the test suite name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing _aws from the test suite name seems better to me.

Copy link
Contributor

@willthames willthames left a comment

Choose a reason for hiding this comment

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

I've tested this locally, everything looks great. Good to merge from my point of view

Copy link
Contributor

@jillr jillr left a comment

Choose a reason for hiding this comment

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

Overall this looks good, but I'm concerned about the 41MB function.zip. We have to carry this around in the repo (and ansible is already fairly hefty), and I'm getting timeouts on the "register lambda" test some of the time. This will likely lead to these tests being unstable in CI. It would be better to use a simple hello world style script like test/integration/targets/aws_lambda/files/mini_lambda.py or test/integration/targets/lambda_policy/files/mini_http_lambda.py.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 17, 2019
@jillr
Copy link
Contributor

jillr commented Jul 17, 2019

I'd also personally prefer it if the function were in-repo as a regular file, then zipped in the test, from a review and accounting perspective. It makes it much easier to track and ensure that nothing is sneaking into the repo via a binary.

- name: move lambda into place for archive module
copy:
src: "function.zip"
dest: "{{output_dir}}/function.zip"
Copy link
Member

Choose a reason for hiding this comment

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

We should not include a file of this size in the repo. Use a very tiny lambda function and create the zip file during the test. If that's not possible, then we can put the zip file in our S3 bucket for CI -- but lets avoid that if possible.

Copy link
Member

Choose a reason for hiding this comment

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

Ideally the lambda would be a singe python file with no requirements outside the standard library, then no zip would be needed. Keeping it python vs another language makes it easier to review since most contributors will be familiar with python.

@aljazkosir
Copy link
Contributor Author

@jillr @mattclay Of course, I totally forgot about that zip, sorry about that. It is now zipped during the test without any extra requirements, so it should be fairly small.
ready_for_review

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jul 18, 2019
@mattclay mattclay dismissed their stale review July 18, 2019 06:45

Dismissing out-of-date review.

@aljazkosir
Copy link
Contributor Author

I changed the authors, so the right people will be pinged.

@ansibot
Copy link
Contributor

ansibot commented Jul 18, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/s3_bucket_notification.py:0:0: E305 DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got ['XLAB Steampunk d.o.o. (@xlab-si/steampunk)']

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Jul 18, 2019
@ansibot
Copy link
Contributor

ansibot commented Jul 18, 2019

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/s3_bucket_notification.py:29:0: SyntaxError: Non-ASCII character '\xc5' in file /root/ansible/lib/ansible/modules/cloud/amazon/s3_bucket_notification.py on line 30, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/amazon/s3_bucket_notification.py:29:0: SyntaxError: Non-ASCII character '\xc5' in file /root/ansible/lib/ansible/modules/cloud/amazon/s3_bucket_notification.py on line 30, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

click here for bot help

@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jul 18, 2019
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jul 18, 2019
Copy link
Contributor

@jillr jillr left a comment

Choose a reason for hiding this comment

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

Thanks @aljazkosir that looks much better, appreciate all your work on this module!

@jillr jillr merged commit 42073b6 into ansible:devel Jul 18, 2019
@ansible ansible locked and limited conversation to collaborators Aug 15, 2019
@tadeboro tadeboro deleted the add-lambda-bucket-event-module branch April 14, 2020 06:35
@tadeboro tadeboro restored the add-lambda-bucket-event-module branch April 14, 2020 06:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 aws cloud core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants