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

Added support for InputTransformer attribute of cloudwatchevent_rule #623

Merged

Conversation

avishayil
Copy link
Contributor

@avishayil avishayil commented Jul 3, 2021

SUMMARY

EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

aws.cloudwatchevent_rule

ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review feature This issue/PR relates to a feature request module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) labels Jul 3, 2021
Copy link
Member

@markuman markuman left a comment

Choose a reason for hiding this comment

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

LGTM.
Unfortunately we still have no integrationtests for cloudwatchevent_rule.
Do you find some time to add them?

plugins/modules/cloudwatchevent_rule.py Show resolved Hide resolved
@avishayil
Copy link
Contributor Author

LGTM.
Unfortunately we still have no integrationtests for cloudwatchevent_rule.
Do you find some time to add them?

Sure, do you want me to do it in the context of this PR or on another PR?

@markuman
Copy link
Member

markuman commented Jul 8, 2021

LGTM.
Unfortunately we still have no integrationtests for cloudwatchevent_rule.
Do you find some time to add them?

Sure, do you want me to do it in the context of this PR or on another PR?

the same is fine.

@avishayil
Copy link
Contributor Author

avishayil commented Jul 9, 2021

@markuman I added integration tests, please review.

The automated tests are failing for authorization and timeouts, things I cannot really control

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.

@avishayil Thank you very much for taking the time to work on this. Overall this looks good to me. For the authorization errors, there is required a policy for DescribeRule to be added in the terminator https://github.com/mattclay/aws-terminator. Would you be willing to open a PR in the terminator https://github.com/mattclay/aws-terminator to add this policy? Let me know if you need any help, otherwise I can add it for you.

plugins/modules/cloudwatchevent_rule.py Show resolved Hide resolved
@avishayil
Copy link
Contributor Author

avishayil commented Jul 9, 2021

@avishayil Thank you very much for taking the time to work on this. Overall this looks good to me. For the authorization errors, there is required a policy for DescribeRule to be added in the terminator https://github.com/mattclay/aws-terminator. Would you be willing to open a PR in the terminator https://github.com/mattclay/aws-terminator to add this policy? Let me know if you need any help, otherwise I can add it for you.

Hi @alinabuzachis,

I wasn't sure under what yaml file should I add the permission, but here's the PR:
mattclay/aws-terminator#155

Regarding the version_added, I added it, however I didn't find any similar pattern in some random modules I browsed to get some reference on how to do it, so let me know if it's ok. Relevant commit: avishayil@2c71f9e

Regarding the timeout, any idea?

@ansibullbot
Copy link

@avishayil this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibullbot ansibullbot added 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 and removed community_review labels Jul 16, 2021
@avishayil
Copy link
Contributor Author

@avishayil this PR contains the following merge commits:

* [3e85acc](https://github.com/ansible-collections/community.aws/commit/3e85acc1eafb1b5f7b3b2f6a284ee3a543a48d6c)

Please rebase your branch to remove these commits.

click here for bot help

rebased

@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 Jul 16, 2021
@jillr
Copy link
Collaborator

jillr commented Jul 22, 2021

recheck

@avishayil
Copy link
Contributor Author

recheck

I think the docs error in zuul is unrelated to this PR?

@avishayil
Copy link
Contributor Author

recheck

Any progress?

@avishayil
Copy link
Contributor Author

Hi @jillr @markuman any news?

@alinabuzachis
Copy link
Contributor

recheck

@avishayil
Copy link
Contributor Author

Hi @alinabuzachis happy to see we're back on track!

@alinabuzachis
Copy link
Contributor

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

ansible-galaxy-importer FAILURE in 4m 33s (non-voting)
✔️ build-ansible-collection SUCCESS in 4m 56s
✔️ ansible-test-sanity-docker-devel SUCCESS in 10m 22s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 10m 45s
✔️ ansible-test-sanity-docker-stable-2.9 SUCCESS in 13m 08s
✔️ ansible-test-sanity-docker-stable-2.11 SUCCESS in 11m 27s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 58s
✔️ ansible-test-units-community-aws-python38 SUCCESS in 6m 17s
✔️ ansible-test-splitter SUCCESS in 3m 24s
✔️ integration-community.aws-1 SUCCESS in 5m 49s
⚠️ 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

@tremble
Copy link
Contributor

tremble commented Jul 5, 2022

recheck

avishayil and others added 4 commits July 5, 2022 17:17
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Thanks for adding the minimal integration tests.

I'm sorry this has taken so long, assuming the tests pass I think this is ready to merge.

@github-actions
Copy link

github-actions bot commented Jul 5, 2022

Docs Build 📝

Thank you for contribution!✨

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

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 4m 37s (non-voting)
✔️ build-ansible-collection SUCCESS in 5m 33s
✔️ ansible-test-sanity-docker-devel SUCCESS in 9m 39s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 9m 51s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 9m 36s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 11m 18s
✔️ ansible-test-units-community-aws-python38 SUCCESS in 7m 25s
✔️ ansible-test-units-community-aws-python39 SUCCESS in 6m 21s
✔️ ansible-test-splitter SUCCESS in 2m 30s
✔️ integration-community.aws-1 SUCCESS in 5m 52s
⚠️ 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

@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Jul 5, 2022
@avishayil
Copy link
Contributor Author

Thanks, it's been over a year 🙏

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 4m 07s (non-voting)
✔️ build-ansible-collection SUCCESS in 4m 56s
✔️ ansible-test-sanity-docker-devel SUCCESS in 11m 13s (non-voting)
✔️ ansible-test-sanity-docker-milestone SUCCESS in 12m 16s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 9m 40s
✔️ ansible-test-sanity-docker-stable-2.13 SUCCESS in 10m 08s
✔️ ansible-test-units-community-aws-python38 SUCCESS in 6m 32s
✔️ ansible-test-units-community-aws-python39 SUCCESS in 6m 08s
✔️ ansible-test-splitter SUCCESS in 2m 37s
✔️ integration-community.aws-1 SUCCESS in 6m 28s
⚠️ 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

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit bd097b5 into ansible-collections:main Jul 5, 2022
@tremble tremble added the backport-4 PR should be backported to the stable-4 branch label Jul 15, 2022
@patchback
Copy link

patchback bot commented Jul 15, 2022

Backport to stable-4: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-4/bd097b5e0f02d471e7ed786a0743ce48844b60c7/pr-623

Backported as #1357

🤖 @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 Jul 15, 2022
…623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>
(cherry picked from commit bd097b5)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Jul 15, 2022
…623) (#1357)

[PR #623/bd097b5e backport][stable-4] Added support for InputTransformer attribute of cloudwatchevent_rule

This is a backport of PR #623 as merged into main (bd097b5).
SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
Fix support envvars for lookup aws ssm

SUMMARY

Took over from ansible-collections#623 to apply reviewer's comments and add a changelog fragment.
Working on support in lookup plugin amazon.aws.aws_ssm for endpoint parameters, as well of tradional environment variable for client configuration (AWS_PROFILE, AWS_ACCESS_KEY_ID, ...).
This should fixes ansible-collections#519
Depends-On: ansible-collections#728
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
It seems LookupModule cannot benefit from AnsibleAWSModule (it expect several methods/params, I am not familiar enough with Python and Ansible to sort it out) ; so this PR uses boto3_conn and get_aws_connection_info defined in utils.ec2.
This is a simple snippet how it can be used:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status', endpoint='http://localhost:4566') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"

Command line test:
ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
Output:
PLAY [Load env] *************************************************************************************************************************************************************************************************************************************************************

TASK [show the env] *********************************************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "INIT"
}

PLAY RECAP ******************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Another test with envars:
AWS_ACCESS_KEY_ID='foo' AWS_ACCESS_SECRET_KEY='bar' AWS_URL='http://localhost:4566' ANSIBLE_COLLECTIONS_PATHS=${ANSIBLE_HOME}/collections ansible-playbook test.yml
where we remove the endpoint from lookup:
- name: Load env
  collections:
  - amazon.aws
  gather_facts: no
  hosts: localhost
  connection: local
  vars:
    my_env: "{{ lookup('amazon.aws.aws_ssm', 'status') }}"
  tasks:
    - name: show the env
      debug:
        msg: "{{ my_env }}"
(provides same output)

Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
…nsible-collections#623)

Added support for InputTransformer attribute of cloudwatchevent_rule

SUMMARY
EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws.cloudwatchevent_rule
ADDITIONAL INFORMATION
    ...
        "targets": [
            {
                "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic",
                "id": "MySNSTopic",
                "input_transformer": {
                    "input_paths_map": {
                        "instance": "$.detail.instance-id",
                        "state": "$.detail.state"
                    },
                    "input_template": "\"<instance> is in state <state>\""
                }
            }
        ]

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: Avishay Bar <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Mark Chappell <None>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections@bd097b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-4 PR should be backported to the stable-4 branch community_review feature This issue/PR relates to a feature request integration tests/integration mergeit Merge the PR (SoftwareFactory) module module new_contributor Help guide this first time contributor plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants