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

lambda_event: Add support for FunctionResponseTypes #1209

Conversation

mandar242
Copy link
Contributor

@mandar242 mandar242 commented Oct 26, 2022

SUMMARY

Resolves #1081
Added support to set FunctionResponseTypes when creating lambda event source mappings

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lambda_event

ADDITIONAL INFORMATION

Can be tested using below playbook (needs a dynamo db table and lambda function with appropriate access/policy/role)

---
- name: lambda_event
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Create DynamoDB stream event mapping (trigger)
      amazon.aws.lambda_event:
        state: present
        event_source: stream
        function_name: my-test-function
        source_params:
          source_arn: arn:aws:dynamodb:us-east-2:721234567890:table/my-test-table/stream/2022-10-26T17:55:25.232
          enabled: True
          batch_size: 500
          starting_position: LATEST
          function_response_types:
            - ReportBatchItemFailures
      register: event

    - name: Get info on above trigger
      command: 'aws lambda get-event-source-mapping --uuid {{ event.events.uuid }}'
      environment:
        AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
        AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
        AWS_SESSION_TOKEN: "{{ security_token | default('') }}"
        AWS_DEFAULT_REGION: "{{ aws_region }}"
      register: my_function_details

    - name: convert it to an object
      set_fact:
        my_function_details_obj: "{{ my_function_details.stdout | from_json }}"

    - assert:
        that:
          - my_function_details_obj.FunctionResponseTypes is defined
          - my_function_details_obj.FunctionResponseTypes | length > 0
          - my_function_details_obj.FunctionResponseTypes[0] == "ReportBatchItemFailures"

@github-actions
Copy link

github-actions bot commented Oct 26, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review feature This issue/PR relates to a feature request module module needs_triage plugins plugin (any type) labels Oct 26, 2022
@softwarefactory-project-zuul

This comment was marked as outdated.

- (Streams and Amazon SQS) A list of current response type enums applied to the event source mapping.
type: list
elements: str
choices: [ReportBatchItemFailures]
Copy link
Contributor

Choose a reason for hiding this comment

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

only one choice and using a list of strings?
Could you please update the parameter and define it as a boolean?

Copy link
Member

Choose a reason for hiding this comment

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

This is coming from the AWS spec. Presumably, they are doing this with the intent that there will be more options in the future. I think we should leave this as is, because it will be much easier to add a new item to this list than to change the parameter type altogether in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abikouo , yes assuming AWS will come up with more choices in future, I kept it as per boto3 documentation.

@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242 mandar242 force-pushed the lambda_event-add_FunctionResponseTypes_support branch from 3b42a31 to e81cb19 Compare October 28, 2022 20:21
@softwarefactory-project-zuul

This comment was marked as outdated.

@GomathiselviS
Copy link
Contributor

@mandar242 I think we should add a testcase to test the newly added key.

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.

@mandar242 Could you please add some tests?

@@ -0,0 +1,2 @@
minor_changes:
- lambda_event - Added support to set FunctionResponseTypes when creating lambda event source mappings (https://github.com/ansible-collections/amazon.aws/pull/1209).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- lambda_event - Added support to set FunctionResponseTypes when creating lambda event source mappings (https://github.com/ansible-collections/amazon.aws/pull/1209).
- lambda_event - Added support to set ``function_response_types`` when creating lambda event source mappings (https://github.com/ansible-collections/amazon.aws/pull/1209).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@GomathiselviS @alinabuzachis currently I don't think we have integration tests for lambda_event, would it be fine to add tests for this PR under integration tests for lambda https://github.com/ansible-collections/amazon.aws/tree/main/tests/integration/targets/lambda ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably go with a new test suite for lambda_event, but it's up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel if it's okay, I'd like to get this PR merged first and open new PR for adding test suite?
@alinabuzachis @gravesm @GomathiselviS

Copy link
Member

Choose a reason for hiding this comment

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

In general, we should really be adding tests along with the code. Tests can often highlight problems with a PR that aren't obvious by just reviewing. There's also the danger that even with the best intentions, the tests never get added later due to any number of reasons.

Copy link
Contributor Author

@mandar242 mandar242 Nov 8, 2022

Choose a reason for hiding this comment

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

Okay, will add test suite to this PR soon.
The reason I was thinking to create another PR for test suite is that, I might be wrong but it does require significant amount of setup for testing lambda_event, need a stream (eg dynamodb table, stream), lambda function, IAM role for proper policies for lambda function.

@mandar242 mandar242 force-pushed the lambda_event-add_FunctionResponseTypes_support branch from e81cb19 to 492a19f Compare November 9, 2022 03:55
@ansibullbot ansibullbot added integration tests/integration tests tests labels Nov 9, 2022
@mandar242
Copy link
Contributor Author

recheck

3 similar comments
@goneri
Copy link
Member

goneri commented Nov 9, 2022

recheck

@goneri
Copy link
Member

goneri commented Nov 9, 2022

recheck

@goneri
Copy link
Member

goneri commented Nov 9, 2022

recheck

@gravesm
Copy link
Member

gravesm commented Nov 10, 2022

recheck

@goneri
Copy link
Member

goneri commented Nov 10, 2022

Sorry, I forgot to remove the Depends-On: ansible/ansible-zuul-jobs#1691

@goneri goneri closed this Nov 10, 2022
@goneri goneri reopened this Nov 10, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 09s
✔️ build-ansible-collection SUCCESS in 5m 23s
ansible-test-sanity-aws-ansible-python38 FAILURE in 8m 29s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 32s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 16s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 9m 23s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 7m 36s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 7m 58s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 01s
✔️ cloud-tox-py3 SUCCESS in 3m 14s
✔️ ansible-test-splitter SUCCESS in 2m 24s
integration-amazon.aws-1 FAILURE in 8m 52s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 06s
✔️ noop SUCCESS in 0s

@mandar242
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 16s
✔️ build-ansible-collection SUCCESS in 4m 52s
ansible-test-sanity-aws-ansible-python38 FAILURE in 9m 11s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 8m 55s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 8m 22s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 8m 45s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 28s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 59s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 13s
✔️ cloud-tox-py3 SUCCESS in 3m 15s
✔️ ansible-test-splitter SUCCESS in 3m 02s
integration-amazon.aws-1 FAILURE in 9m 45s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 03s
✔️ noop SUCCESS in 0s

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 16s
✔️ build-ansible-collection SUCCESS in 5m 33s
ansible-test-sanity-aws-ansible-python38 FAILURE in 8m 54s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 38s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 8m 52s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 9m 30s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 14s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 56s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 03s
✔️ cloud-tox-py3 SUCCESS in 3m 22s
✔️ ansible-test-splitter SUCCESS in 2m 19s
integration-amazon.aws-1 FAILURE in 7m 34s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 03s
✔️ noop SUCCESS in 0s

@mandar242
Copy link
Contributor Author

recheck

Copy link
Member

@gravesm gravesm left a comment

Choose a reason for hiding this comment

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

I believe you need to set the botocore version. The tests pass for me locally.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 4m 03s
✔️ build-ansible-collection SUCCESS in 5m 59s
ansible-test-sanity-aws-ansible-python38 FAILURE in 8m 55s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 10m 20s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 12m 11s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 9m 33s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 06s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 55s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 5m 58s
✔️ cloud-tox-py3 SUCCESS in 3m 16s
✔️ ansible-test-changelog SUCCESS in 2m 16s
✔️ ansible-test-splitter SUCCESS in 2m 24s
✔️ integration-amazon.aws-1 SUCCESS in 10m 42s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

@goneri goneri added the mergeit Merge the PR (SoftwareFactory) label Nov 16, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 4m 07s
✔️ build-ansible-collection SUCCESS in 5m 56s
✔️ ansible-test-splitter SUCCESS in 2m 56s
✔️ integration-amazon.aws-1 SUCCESS in 8m 31s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit cc2f587 into ansible-collections:main Nov 16, 2022
alinabuzachis pushed a commit to alinabuzachis/amazon.aws that referenced this pull request Apr 27, 2023
…ons#1209)

lambda_event: Add support for FunctionResponseTypes

SUMMARY

Resolves ansible-collections#1081
Added support to set FunctionResponseTypes when creating lambda event source mappings

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

lambda_event
ADDITIONAL INFORMATION


Can be tested using below playbook (needs a dynamo db table and lambda function with appropriate access/policy/role)

---
- name: lambda_event
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Create DynamoDB stream event mapping (trigger)
      amazon.aws.lambda_event:
        state: present
        event_source: stream
        function_name: my-test-function
        source_params:
          source_arn: arn:aws:dynamodb:us-east-2:721234567890:table/my-test-table/stream/2022-10-26T17:55:25.232
          enabled: True
          batch_size: 500
          starting_position: LATEST
          function_response_types:
            - ReportBatchItemFailures
      register: event

    - name: Get info on above trigger
      command: 'aws lambda get-event-source-mapping --uuid {{ event.events.uuid }}'
      environment:
        AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
        AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
        AWS_SESSION_TOKEN: "{{ security_token | default('') }}"
        AWS_DEFAULT_REGION: "{{ aws_region }}"
      register: my_function_details

    - name: convert it to an object
      set_fact:
        my_function_details_obj: "{{ my_function_details.stdout | from_json }}"

    - assert:
        that:
          - my_function_details_obj.FunctionResponseTypes is defined
          - my_function_details_obj.FunctionResponseTypes | length > 0
          - my_function_details_obj.FunctionResponseTypes[0] == "ReportBatchItemFailures"

Reviewed-by: Bikouo Aubin <None>
Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: GomathiselviS <None>
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Apr 28, 2023
[manual backport stable-5] lambda_event: Add support for FunctionResponseTypes (#1209)

lambda_event: Add support for FunctionResponseTypes
SUMMARY
Resolves #1081
Added support to set FunctionResponseTypes when creating lambda event source mappings
ISSUE TYPE
Feature Pull Request
COMPONENT NAME
lambda_event
ADDITIONAL INFORMATION
Can be tested using below playbook (needs a dynamo db table and lambda function with appropriate access/policy/role)



name: lambda_event hosts: localhost gather_facts: false tasks: - name: Create DynamoDB stream event mapping (trigger) amazon.aws.lambda_event: state: present event_source: stream function_name: my-test-function source_params: source_arn: arn:aws:dynamodb:us-east-2:721234567890:table/my-test-table/stream/2022-10-26T17:55:25.232 enabled: True batch_size: 500 starting_position: LATEST function_response_types: - ReportBatchItemFailures register: event


name: Get info on above trigger
command: 'aws lambda get-event-source-mapping --uuid {{ event.events.uuid }}'
environment:
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
AWS_SESSION_TOKEN: "{{ security_token | default('') }}"
AWS_DEFAULT_REGION: "{{ aws_region }}"
register: my_function_details


name: convert it to an object
set_fact:
my_function_details_obj: "{{ my_function_details.stdout | from_json }}"


assert:
that:
- my_function_details_obj.FunctionResponseTypes is defined
- my_function_details_obj.FunctionResponseTypes | length > 0 - my_function_details_obj.FunctionResponseTypes[0] == "ReportBatchItemFailures"




Reviewed-by: Bikouo Aubin 
Reviewed-by: Mike Graves mgraves@redhat.com
Reviewed-by: Mandar Kulkarni mandar242@gmail.com
Reviewed-by: Alina Buzachis 
Reviewed-by: Gonéri Le Bouder goneri@lebouder.net
Reviewed-by: GomathiselviS 
SUMMARY


ISSUE TYPE


Bugfix Pull Request
Docs Pull Request
Feature Pull Request
New Module Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION
@mandar242 mandar242 deleted the lambda_event-add_FunctionResponseTypes_support branch May 9, 2023 02:46
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…`` (ansible-collections#1212)

ecs_* - fix idempotence bug in ecs_service and dont require ``cluster``

SUMMARY

Don't require cluster param and use cluster name 'default' when not specified (see docs).
Fix bug when comparing health_check_grace_period_seconds when not input by user.


ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ecs_service
ecs_task

ADDITIONAL INFORMATION
Split up from ansible-collections#1209 to backport to stable-2

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
SUMMARY

    Add wait parameter to utilize boto3 waiters in ecs_service and ecs_task (ServicesInactive, TasksStopped, TasksRunning).
    There's an additional waiter for ServicesStable but idempotence checked never failed locally so it seems redundant when creating a service.

ISSUE TYPE

    Feature Pull Request

COMPONENT NAME

    ecs_service
    ecs_task

ADDITIONAL INFORMATION

When testing the waiter for TasksRunning, tests failed on waiter error due to the container instance not being able to be created, not because of the waiter, so I commented out those tests for now.

In the ECS console:

Stopped reason CannotPullContainerError: inspect image has been retried 5 time(s): failed to resolve ref "docker.io/library/nginx:latest": failed to do request: Head https://registry-1.docker.io/v2/library/nginx/manifests/latest: dial tcp 34.237.244.67:443: i/o timeout



* add waiters and fix some bugs
* add changelog
* move bugfixes to different PR for backporting purposes
* update wait description
* catch WaiterError
* Bump version_added
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…`` (ansible-collections#1212)

ecs_* - fix idempotence bug in ecs_service and dont require ``cluster``

SUMMARY

Don't require cluster param and use cluster name 'default' when not specified (see docs).
Fix bug when comparing health_check_grace_period_seconds when not input by user.


ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ecs_service
ecs_task

ADDITIONAL INFORMATION
Split up from ansible-collections#1209 to backport to stable-2

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Alina Buzachis <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
SUMMARY

    Add wait parameter to utilize boto3 waiters in ecs_service and ecs_task (ServicesInactive, TasksStopped, TasksRunning).
    There's an additional waiter for ServicesStable but idempotence checked never failed locally so it seems redundant when creating a service.

ISSUE TYPE

    Feature Pull Request

COMPONENT NAME

    ecs_service
    ecs_task

ADDITIONAL INFORMATION

When testing the waiter for TasksRunning, tests failed on waiter error due to the container instance not being able to be created, not because of the waiter, so I commented out those tests for now.

In the ECS console:

Stopped reason CannotPullContainerError: inspect image has been retried 5 time(s): failed to resolve ref "docker.io/library/nginx:latest": failed to do request: Head https://registry-1.docker.io/v2/library/nginx/manifests/latest: dial tcp 34.237.244.67:443: i/o timeout



* add waiters and fix some bugs
* add changelog
* move bugfixes to different PR for backporting purposes
* update wait description
* catch WaiterError
* Bump version_added
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…`` (ansible-collections#1212)

ecs_* - fix idempotence bug in ecs_service and dont require ``cluster``

SUMMARY

Don't require cluster param and use cluster name 'default' when not specified (see docs).
Fix bug when comparing health_check_grace_period_seconds when not input by user.


ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

ecs_service
ecs_task

ADDITIONAL INFORMATION
Split up from ansible-collections#1209 to backport to stable-2

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

    Add wait parameter to utilize boto3 waiters in ecs_service and ecs_task (ServicesInactive, TasksStopped, TasksRunning).
    There's an additional waiter for ServicesStable but idempotence checked never failed locally so it seems redundant when creating a service.

ISSUE TYPE

    Feature Pull Request

COMPONENT NAME

    ecs_service
    ecs_task

ADDITIONAL INFORMATION

When testing the waiter for TasksRunning, tests failed on waiter error due to the container instance not being able to be created, not because of the waiter, so I commented out those tests for now.

In the ECS console:

Stopped reason CannotPullContainerError: inspect image has been retried 5 time(s): failed to resolve ref "docker.io/library/nginx:latest": failed to do request: Head https://registry-1.docker.io/v2/library/nginx/manifests/latest: dial tcp 34.237.244.67:443: i/o timeout



* add waiters and fix some bugs
* add changelog
* move bugfixes to different PR for backporting purposes
* update wait description
* catch WaiterError
* Bump version_added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Add support for FunctionResponseTypes in lambda_event module
7 participants